Make event loop implementations final
This commit is contained in:
parent
44ac15ab78
commit
b74e5aa4ee
@ -34,7 +34,7 @@ extern (C) nothrow @nogc
|
|||||||
int epoll_wait (int epfd, epoll_event *events, int maxevents, int timeout);
|
int epoll_wait (int epfd, epoll_event *events, int maxevents, int timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
class EpollLoop : SelectorLoop
|
final class EpollLoop : SelectorLoop
|
||||||
{
|
{
|
||||||
protected int fd;
|
protected int fd;
|
||||||
private Vector!epoll_event events;
|
private Vector!epoll_event events;
|
||||||
|
@ -26,7 +26,7 @@ import core.sys.windows.winbase;
|
|||||||
import core.sys.windows.windef;
|
import core.sys.windows.windef;
|
||||||
import core.sys.windows.winsock2;
|
import core.sys.windows.winsock2;
|
||||||
|
|
||||||
class IOCPStreamTransport : StreamTransport
|
final class IOCPStreamTransport : StreamTransport
|
||||||
{
|
{
|
||||||
private WriteBuffer!ubyte input;
|
private WriteBuffer!ubyte input;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class IOCPStreamTransport : StreamTransport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IOCPLoop : Loop
|
final class IOCPLoop : Loop
|
||||||
{
|
{
|
||||||
protected HANDLE completionPort;
|
protected HANDLE completionPort;
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ extern(C) int kevent(int kq, const kevent_t *changelist, int nchanges,
|
|||||||
kevent_t *eventlist, int nevents, const timespec *timeout)
|
kevent_t *eventlist, int nevents, const timespec *timeout)
|
||||||
nothrow @nogc;
|
nothrow @nogc;
|
||||||
|
|
||||||
class KqueueLoop : SelectorLoop
|
final class KqueueLoop : SelectorLoop
|
||||||
{
|
{
|
||||||
protected int fd;
|
protected int fd;
|
||||||
private Vector!kevent_t events;
|
private Vector!kevent_t events;
|
||||||
|
@ -25,7 +25,7 @@ import tanya.network.socket;
|
|||||||
/**
|
/**
|
||||||
* Transport for stream sockets.
|
* Transport for stream sockets.
|
||||||
*/
|
*/
|
||||||
class SelectorStreamTransport : IOWatcher, StreamTransport
|
final class SelectorStreamTransport : IOWatcher, StreamTransport
|
||||||
{
|
{
|
||||||
/// Input buffer.
|
/// Input buffer.
|
||||||
package WriteBuffer!ubyte input;
|
package WriteBuffer!ubyte input;
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright: Eugene Wissner 2016-2017.
|
|
||||||
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
|
|
||||||
* Mozilla Public License, v. 2.0).
|
|
||||||
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
|
|
||||||
*/
|
|
||||||
module tanya.container.string;
|
|
||||||
|
|
||||||
import core.exception;
|
|
||||||
import core.stdc.string;
|
|
||||||
import tanya.memory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UTF-8 string.
|
|
||||||
*/
|
|
||||||
struct String
|
|
||||||
{
|
|
||||||
private char[] data;
|
|
||||||
private size_t length_;
|
|
||||||
|
|
||||||
invariant
|
|
||||||
{
|
|
||||||
assert(length_ <= data.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ditto.
|
|
||||||
this(const(char)[] str, shared Allocator allocator = defaultAllocator)
|
|
||||||
nothrow @trusted @nogc
|
|
||||||
{
|
|
||||||
this(allocator);
|
|
||||||
|
|
||||||
data = cast(char[]) allocator.allocate(str.length);
|
|
||||||
if (str.length > 0 && data is null)
|
|
||||||
{
|
|
||||||
onOutOfMemoryErrorNoGC();
|
|
||||||
}
|
|
||||||
memcpy(data.ptr, str.ptr, str.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ditto.
|
|
||||||
this(const(wchar)[] str, shared Allocator allocator = defaultAllocator)
|
|
||||||
nothrow @trusted @nogc
|
|
||||||
{
|
|
||||||
this(allocator);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ditto.
|
|
||||||
this(const(dchar)[] str, shared Allocator allocator = defaultAllocator)
|
|
||||||
nothrow @trusted @nogc
|
|
||||||
{
|
|
||||||
this(allocator);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ditto.
|
|
||||||
this(shared Allocator allocator) pure nothrow @safe @nogc
|
|
||||||
in
|
|
||||||
{
|
|
||||||
assert(allocator !is null);
|
|
||||||
}
|
|
||||||
body
|
|
||||||
{
|
|
||||||
allocator_ = allocator;
|
|
||||||
}
|
|
||||||
|
|
||||||
~this() nothrow @trusted @nogc
|
|
||||||
{
|
|
||||||
allocator.deallocate(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
mixin DefaultAllocator;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user