Implement protocol property for IOCPTransport
This commit is contained in:
parent
48a49c2a2d
commit
63c6226a2a
@ -30,30 +30,70 @@ class IOCPStreamTransport : StreamTransport
|
|||||||
{
|
{
|
||||||
private OverlappedConnectedSocket socket_;
|
private OverlappedConnectedSocket socket_;
|
||||||
|
|
||||||
|
private Protocol protocol_;
|
||||||
|
|
||||||
private WriteBuffer!ubyte input;
|
private WriteBuffer!ubyte input;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new completion port transport.
|
* Creates new completion port transport.
|
||||||
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* socket = Socket.
|
* socket = Socket.
|
||||||
|
* protocol = Application protocol.
|
||||||
|
*
|
||||||
|
* Precondition: $(D_INLINECODE socket !is null && protocol !is null)
|
||||||
*/
|
*/
|
||||||
this(OverlappedConnectedSocket socket) @nogc
|
this(OverlappedConnectedSocket socket, Protocol protocol) @nogc
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
assert(socket !is null);
|
assert(socket !is null);
|
||||||
|
assert(protocol !is null);
|
||||||
}
|
}
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
socket_ = socket;
|
socket_ = socket;
|
||||||
|
protocol_ = protocol;
|
||||||
input = WriteBuffer!ubyte(8192, MmapPool.instance);
|
input = WriteBuffer!ubyte(8192, MmapPool.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@property inout(OverlappedConnectedSocket) socket()
|
/**
|
||||||
inout pure nothrow @safe @nogc
|
* Returns: Socket.
|
||||||
|
*/
|
||||||
|
@property OverlappedConnectedSocket socket() pure nothrow @safe @nogc
|
||||||
{
|
{
|
||||||
return socket_;
|
return socket_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns: Application protocol.
|
||||||
|
*/
|
||||||
|
@property Protocol protocol() pure nothrow @safe @nogc
|
||||||
|
{
|
||||||
|
return protocol_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switches the protocol.
|
||||||
|
*
|
||||||
|
* The protocol is deallocated by the event loop, it should currently be
|
||||||
|
* allocated with $(D_PSYMBOL MmapPool).
|
||||||
|
*
|
||||||
|
* Params:
|
||||||
|
* protocol = Application protocol.
|
||||||
|
*
|
||||||
|
* Precondition: $(D_INLINECODE protocol !is null)
|
||||||
|
*/
|
||||||
|
@property void protocol(Protocol protocol) pure nothrow @safe @nogc
|
||||||
|
in
|
||||||
|
{
|
||||||
|
assert(protocol !is null);
|
||||||
|
}
|
||||||
|
body
|
||||||
|
{
|
||||||
|
protocol_ = protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write some data to the transport.
|
* Write some data to the transport.
|
||||||
*
|
*
|
||||||
@ -215,8 +255,9 @@ class IOCPLoop : Loop
|
|||||||
assert(listener !is null);
|
assert(listener !is null);
|
||||||
|
|
||||||
auto socket = listener.endAccept(overlapped);
|
auto socket = listener.endAccept(overlapped);
|
||||||
auto transport = MmapPool.instance.make!IOCPStreamTransport(socket);
|
auto protocol = connection.protocol;
|
||||||
auto io = MmapPool.instance.make!IOWatcher(transport, connection.protocol);
|
auto transport = MmapPool.instance.make!IOCPStreamTransport(socket, protocol);
|
||||||
|
auto io = MmapPool.instance.make!IOWatcher(transport, protocol);
|
||||||
|
|
||||||
connection.incoming.enqueue(io);
|
connection.incoming.enqueue(io);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class SelectorStreamTransport : StreamTransport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns: Transport socket.
|
* Returns: Socket.
|
||||||
*/
|
*/
|
||||||
ConnectedSocket socket() pure nothrow @safe @nogc
|
ConnectedSocket socket() pure nothrow @safe @nogc
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,9 @@ interface DuplexTransport : ReadTransport, WriteTransport
|
|||||||
*/
|
*/
|
||||||
interface SocketTransport : Transport
|
interface SocketTransport : Transport
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Returns: Socket.
|
||||||
|
*/
|
||||||
@property Socket socket() pure nothrow @safe @nogc;
|
@property Socket socket() pure nothrow @safe @nogc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user