Loop.maxEvents is const, not inout const

This commit is contained in:
Eugen Wissner 2017-01-12 10:43:02 +01:00
parent cb6cc65113
commit 8ddea0aa46
4 changed files with 17 additions and 26 deletions

View File

@ -46,7 +46,7 @@ class EpollLoop : SelectorLoop
{ {
if ((fd = epoll_create1(EPOLL_CLOEXEC)) < 0) if ((fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
{ {
throw MmapPool.instance.make!BadLoopException("epoll initialization failed"); throw defaultAllocator.make!BadLoopException("epoll initialization failed");
} }
super(); super();
events = Vector!epoll_event(maxEvents, MmapPool.instance); events = Vector!epoll_event(maxEvents, MmapPool.instance);

View File

@ -124,8 +124,8 @@ class KqueueLoop : SelectorLoop
* Returns: Maximal event count can be got at a time * Returns: Maximal event count can be got at a time
* (should be supported by the backend). * (should be supported by the backend).
*/ */
override protected @property inout(uint) maxEvents() override protected @property uint maxEvents()
inout const pure nothrow @safe @nogc const pure nothrow @safe @nogc
{ {
return cast(uint) events.length; return cast(uint) events.length;
} }

View File

@ -137,8 +137,8 @@ abstract class Loop
* Returns: Maximal event count can be got at a time * Returns: Maximal event count can be got at a time
* (should be supported by the backend). * (should be supported by the backend).
*/ */
protected @property inout(uint) maxEvents() protected @property uint maxEvents()
inout const pure nothrow @safe @nogc const pure nothrow @safe @nogc
{ {
return 128U; return 128U;
} }

View File

@ -261,7 +261,6 @@ struct ReadBuffer(T = ubyte)
allocator.reallocate(buf, (cap + blockSize) * T.sizeof); allocator.reallocate(buf, (cap + blockSize) * T.sizeof);
buffer_ = cast(T[]) buf; buffer_ = cast(T[]) buf;
}(); }();
buffer_[cap .. $] = T.init;
} }
ring = length_; ring = length_;
return buffer_[length_ .. $]; return buffer_[length_ .. $];
@ -337,33 +336,25 @@ struct WriteBuffer(T = ubyte)
* size = Initial buffer size and the size by which the buffer will * size = Initial buffer size and the size by which the buffer will
* grow. * grow.
* allocator = Allocator. * allocator = Allocator.
*
* Precondition: $(D_INLINECODE size > 0 && allocator !is null)
*/ */
this(in size_t size, shared Allocator allocator = defaultAllocator) @trusted this(in size_t size, shared Allocator allocator = defaultAllocator) @trusted
in in
{ {
assert(size > 0); assert(size > 0);
assert(allocator !is null);
} }
body body
{ {
blockSize = size; blockSize = size;
ring = size - 1; ring = size - 1;
this(allocator); allocator_ = allocator;
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof); buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
} }
@disable this(); @disable this();
/// Ditto.
this(shared Allocator allocator)
in
{
assert(allocator !is null);
}
body
{
allocator_ = allocator;
}
/** /**
* Deallocates the internal buffer. * Deallocates the internal buffer.
*/ */