Make allocator shared and fix some RefCounted bugs
This commit is contained in:
@@ -107,7 +107,7 @@ class EpollLoop : SelectorLoop
|
||||
{
|
||||
if (errno != EINTR)
|
||||
{
|
||||
throw theAllocator.make!BadLoopException();
|
||||
throw defaultAllocator.make!BadLoopException();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ class IOCPStreamTransport : StreamTransport
|
||||
body
|
||||
{
|
||||
socket_ = socket;
|
||||
input = MmapPool.instance.make!WriteBuffer();
|
||||
input = MmapPool.instance.make!WriteBuffer(8192, MmapPool.instance);
|
||||
}
|
||||
|
||||
~this()
|
||||
@@ -101,7 +101,8 @@ class IOCPStreamTransport : StreamTransport
|
||||
completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
|
||||
if (!completionPort)
|
||||
{
|
||||
throw theAllocator.make!BadLoopException("Creating completion port failed");
|
||||
throw make!BadLoopException(defaultAllocator,
|
||||
"Creating completion port failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ class IOCPStreamTransport : StreamTransport
|
||||
catch (SocketException e)
|
||||
{
|
||||
MmapPool.instance.dispose(overlapped);
|
||||
theAllocator.dispose(e);
|
||||
defaultAllocator.dispose(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +174,7 @@ class IOCPStreamTransport : StreamTransport
|
||||
catch (SocketException e)
|
||||
{
|
||||
MmapPool.instance.dispose(overlapped);
|
||||
theAllocator.dispose(e);
|
||||
defaultAllocator.dispose(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -250,7 +250,7 @@ class KqueueLoop : SelectorLoop
|
||||
{
|
||||
if (errno != EINTR)
|
||||
{
|
||||
throw theAllocator.make!BadLoopException();
|
||||
throw defaultAllocatorAllocator.make!BadLoopException();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ class SelectorStreamTransport : StreamTransport
|
||||
{
|
||||
socket_ = socket;
|
||||
this.loop = loop;
|
||||
input = MmapPool.instance.make!WriteBuffer();
|
||||
input = MmapPool.instance.make!WriteBuffer(8192, MmapPool.instance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +224,7 @@ abstract class SelectorLoop : Loop
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
theAllocator.dispose(e);
|
||||
defaultAllocator.dispose(e);
|
||||
break;
|
||||
}
|
||||
if (client is null)
|
||||
|
@@ -34,31 +34,31 @@
|
||||
*
|
||||
* void main()
|
||||
* {
|
||||
* auto address = theAllocator.make!InternetAddress("127.0.0.1", cast(ushort) 8192);
|
||||
* auto address = defaultAllocator.make!InternetAddress("127.0.0.1", cast(ushort) 8192);
|
||||
*
|
||||
* version (Windows)
|
||||
* {
|
||||
* auto sock = theAllocator.make!OverlappedStreamSocket(AddressFamily.INET);
|
||||
* auto sock = defaultAllocator.make!OverlappedStreamSocket(AddressFamily.INET);
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* auto sock = theAllocator.make!StreamSocket(AddressFamily.INET);
|
||||
* auto sock = defaultAllocator.make!StreamSocket(AddressFamily.INET);
|
||||
* sock.blocking = false;
|
||||
* }
|
||||
*
|
||||
* sock.bind(address);
|
||||
* sock.listen(5);
|
||||
*
|
||||
* auto io = theAllocator.make!ConnectionWatcher(sock);
|
||||
* auto io = defaultAllocator.make!ConnectionWatcher(sock);
|
||||
* io.setProtocol!EchoProtocol;
|
||||
*
|
||||
* defaultLoop.start(io);
|
||||
* defaultLoop.run();
|
||||
*
|
||||
* sock.shutdown();
|
||||
* theAllocator.dispose(io);
|
||||
* theAllocator.dispose(sock);
|
||||
* theAllocator.dispose(address);
|
||||
* defaultAllocator.dispose(io);
|
||||
* defaultAllocator.dispose(sock);
|
||||
* defaultAllocator.dispose(address);
|
||||
* }
|
||||
* ---
|
||||
*/
|
||||
@@ -278,7 +278,7 @@ abstract class Loop
|
||||
protected void kill(IOWatcher watcher, SocketException exception)
|
||||
{
|
||||
watcher.socket.shutdown();
|
||||
theAllocator.dispose(watcher.socket);
|
||||
defaultAllocator.dispose(watcher.socket);
|
||||
MmapPool.instance.dispose(watcher.transport);
|
||||
watcher.exception = exception;
|
||||
swapPendings.insertBack(watcher);
|
||||
|
@@ -157,7 +157,7 @@ class IOWatcher : ConnectionWatcher
|
||||
super();
|
||||
transport_ = transport;
|
||||
protocol_ = protocol;
|
||||
output = MmapPool.instance.make!ReadBuffer();
|
||||
output = MmapPool.instance.make!ReadBuffer(8192, 1024, MmapPool.instance);
|
||||
active = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user