Don't allocate watcher queue on the heap
This commit is contained in:
parent
c966b42ac3
commit
0156c5a883
@ -133,6 +133,7 @@ abstract class Loop
|
|||||||
/// Pending watchers.
|
/// Pending watchers.
|
||||||
protected Queue!Watcher* pendings;
|
protected Queue!Watcher* pendings;
|
||||||
|
|
||||||
|
/// Ditto.
|
||||||
protected Queue!Watcher* swapPendings;
|
protected Queue!Watcher* swapPendings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,8 +151,8 @@ abstract class Loop
|
|||||||
*/
|
*/
|
||||||
this() @nogc
|
this() @nogc
|
||||||
{
|
{
|
||||||
pendings = MmapPool.instance.make!(Queue!Watcher);
|
pendings = MmapPool.instance.make!(Queue!Watcher)(MmapPool.instance);
|
||||||
swapPendings = MmapPool.instance.make!(Queue!Watcher);
|
swapPendings = MmapPool.instance.make!(Queue!Watcher)(MmapPool.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class ConnectionWatcher : Watcher
|
|||||||
/// Protocol factory.
|
/// Protocol factory.
|
||||||
protected Protocol delegate() @nogc protocolFactory;
|
protected Protocol delegate() @nogc protocolFactory;
|
||||||
|
|
||||||
package Queue!IOWatcher* incoming;
|
package Queue!IOWatcher incoming;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
@ -62,7 +62,6 @@ class ConnectionWatcher : Watcher
|
|||||||
this(Socket socket) @nogc
|
this(Socket socket) @nogc
|
||||||
{
|
{
|
||||||
socket_ = socket;
|
socket_ = socket;
|
||||||
incoming = MmapPool.instance.make!(Queue!IOWatcher);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ditto.
|
/// Ditto.
|
||||||
@ -72,14 +71,13 @@ class ConnectionWatcher : Watcher
|
|||||||
|
|
||||||
~this() @nogc
|
~this() @nogc
|
||||||
{
|
{
|
||||||
foreach (w; *incoming)
|
foreach (w; incoming)
|
||||||
{
|
{
|
||||||
MmapPool.instance.dispose(w);
|
MmapPool.instance.dispose(w);
|
||||||
}
|
}
|
||||||
MmapPool.instance.dispose(incoming);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Params:
|
* Params:
|
||||||
* P = Protocol should be used.
|
* P = Protocol should be used.
|
||||||
*/
|
*/
|
||||||
@ -114,7 +112,7 @@ class ConnectionWatcher : Watcher
|
|||||||
*/
|
*/
|
||||||
override void invoke() @nogc
|
override void invoke() @nogc
|
||||||
{
|
{
|
||||||
foreach (io; *incoming)
|
foreach (io; incoming)
|
||||||
{
|
{
|
||||||
io.protocol.connected(cast(DuplexTransport) io.transport);
|
io.protocol.connected(cast(DuplexTransport) io.transport);
|
||||||
}
|
}
|
||||||
@ -164,7 +162,7 @@ class IOWatcher : ConnectionWatcher
|
|||||||
/**
|
/**
|
||||||
* Destroys the watcher.
|
* Destroys the watcher.
|
||||||
*/
|
*/
|
||||||
protected ~this() @nogc
|
~this() @nogc
|
||||||
{
|
{
|
||||||
MmapPool.instance.dispose(protocol_);
|
MmapPool.instance.dispose(protocol_);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ struct ReadBuffer(T = ubyte)
|
|||||||
in size_t minAvailable = 1024,
|
in size_t minAvailable = 1024,
|
||||||
shared Allocator allocator = defaultAllocator) @trusted
|
shared Allocator allocator = defaultAllocator) @trusted
|
||||||
{
|
{
|
||||||
this(allocator_);
|
this(allocator);
|
||||||
this.minAvailable = minAvailable;
|
this.minAvailable = minAvailable;
|
||||||
this.blockSize = size;
|
this.blockSize = size;
|
||||||
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
buffer_ = cast(T[]) allocator_.allocate(size * T.sizeof);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user