summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-01-12 10:43:02 +0100
committerEugen Wissner <belka@caraus.de>2017-01-12 10:43:02 +0100
commit8ddea0aa4616336fa1ae7a5dcdafb0be07fb84bd (patch)
tree093bc5420a15d0730099e074cbda806150f7e3d1
parentcb6cc6511374798d13d3a191f2a97dfa293ad9bd (diff)
downloadtanya-8ddea0aa4616336fa1ae7a5dcdafb0be07fb84bd.tar.gz
Loop.maxEvents is const, not inout const
-rw-r--r--source/tanya/async/event/epoll.d2
-rw-r--r--source/tanya/async/event/kqueue.d16
-rw-r--r--source/tanya/async/loop.d4
-rw-r--r--source/tanya/container/buffer.d21
4 files changed, 17 insertions, 26 deletions
diff --git a/source/tanya/async/event/epoll.d b/source/tanya/async/event/epoll.d
index d582366..236e3fa 100644
--- a/source/tanya/async/event/epoll.d
+++ b/source/tanya/async/event/epoll.d
@@ -46,7 +46,7 @@ class EpollLoop : SelectorLoop
{
if ((fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
{
- throw MmapPool.instance.make!BadLoopException("epoll initialization failed");
+ throw defaultAllocator.make!BadLoopException("epoll initialization failed");
}
super();
events = Vector!epoll_event(maxEvents, MmapPool.instance);
diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d
index 47bac9e..eb585a8 100644
--- a/source/tanya/async/event/kqueue.d
+++ b/source/tanya/async/event/kqueue.d
@@ -124,8 +124,8 @@ class KqueueLoop : SelectorLoop
* Returns: Maximal event count can be got at a time
* (should be supported by the backend).
*/
- override protected @property inout(uint) maxEvents()
- inout const pure nothrow @safe @nogc
+ override protected @property uint maxEvents()
+ const pure nothrow @safe @nogc
{
return cast(uint) events.length;
}
@@ -158,12 +158,12 @@ class KqueueLoop : SelectorLoop
changes.length = changeCount + maxEvents;
}
EV_SET(&changes[changeCount],
- cast(ulong) socket,
- filter,
- flags,
- 0U,
- 0L,
- null);
+ cast(ulong) socket,
+ filter,
+ flags,
+ 0U,
+ 0L,
+ null);
++changeCount;
}
diff --git a/source/tanya/async/loop.d b/source/tanya/async/loop.d
index 2d6210d..7130d9e 100644
--- a/source/tanya/async/loop.d
+++ b/source/tanya/async/loop.d
@@ -137,8 +137,8 @@ abstract class Loop
* Returns: Maximal event count can be got at a time
* (should be supported by the backend).
*/
- protected @property inout(uint) maxEvents()
- inout const pure nothrow @safe @nogc
+ protected @property uint maxEvents()
+ const pure nothrow @safe @nogc
{
return 128U;
}
diff --git a/source/tanya/container/buffer.d b/source/tanya/container/buffer.d
index ebe52da..5a9ad21 100644
--- a/source/tanya/container/buffer.d
+++ b/source/tanya/container/buffer.d
@@ -203,7 +203,7 @@ struct ReadBuffer(T = ubyte)
numberRead = fillBuffer(b[], b.free, 0, 10);
b += numberRead;
- result = b[0..$];
+ result = b[0 .. $];
assert(result[0] == 0);
assert(result[1] == 1);
assert(result[9] == 9);
@@ -261,7 +261,6 @@ struct ReadBuffer(T = ubyte)
allocator.reallocate(buf, (cap + blockSize) * T.sizeof);
buffer_ = cast(T[]) buf;
}();
- buffer_[cap .. $] = T.init;
}
ring = length_;
return buffer_[length_ .. $];
@@ -280,7 +279,7 @@ struct ReadBuffer(T = ubyte)
b += numberRead;
assert(b.length == 10);
- result = b[0..$];
+ result = b[0 .. $];
assert(result[0] == 0);
assert(result[9] == 9);
b.clear();
@@ -337,33 +336,25 @@ struct WriteBuffer(T = ubyte)
* size = Initial buffer size and the size by which the buffer will
* grow.
* allocator = Allocator.
+ *
+ * Precondition: $(D_INLINECODE size > 0 && allocator !is null)
*/
this(in size_t size, shared Allocator allocator = defaultAllocator) @trusted
in
{
assert(size > 0);
+ assert(allocator !is null);
}
body
{
blockSize = size;
ring = size - 1;
- this(allocator);
+ allocator_ = allocator;
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
}
@disable this();
- /// Ditto.
- this(shared Allocator allocator)
- in
- {
- assert(allocator !is null);
- }
- body
- {
- allocator_ = allocator;
- }
-
/**
* Deallocates the internal buffer.
*/