mirror of https://github.com/deavminet/dnetd.git
Added `addConnection(Connection)` implementation
This commit is contained in:
parent
a637082c00
commit
1e85b9e17e
|
@ -2,6 +2,8 @@ module dnetd.server;
|
||||||
|
|
||||||
import dnetd.listener;
|
import dnetd.listener;
|
||||||
import dnetd.connection;
|
import dnetd.connection;
|
||||||
|
import std.container.dlist;
|
||||||
|
import core.sync.mutex;
|
||||||
|
|
||||||
public struct ServerConfig
|
public struct ServerConfig
|
||||||
{
|
{
|
||||||
|
@ -20,6 +22,9 @@ public class Server
|
||||||
private Listener[] listeners;
|
private Listener[] listeners;
|
||||||
/* TODO: Latwr add mutex for managing lusteners if we do multi thread removal */
|
/* TODO: Latwr add mutex for managing lusteners if we do multi thread removal */
|
||||||
|
|
||||||
|
private DList!(Connection) connQueue;
|
||||||
|
private Mutex connQueueLock;
|
||||||
|
|
||||||
this(ServerConfig config)
|
this(ServerConfig config)
|
||||||
{
|
{
|
||||||
/* Set the listeners configured */
|
/* Set the listeners configured */
|
||||||
|
@ -30,6 +35,21 @@ public class Server
|
||||||
|
|
||||||
/* Configure all Connection's to use this Server */
|
/* Configure all Connection's to use this Server */
|
||||||
Connection.server = this;
|
Connection.server = this;
|
||||||
|
|
||||||
|
/* Initialize all mutexes */
|
||||||
|
connQueueLock = new Mutex();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConnection(Connection connection)
|
||||||
|
{
|
||||||
|
/* Lock the queue */
|
||||||
|
connQueueLock.lock();
|
||||||
|
|
||||||
|
/* Append the connection to the queue */
|
||||||
|
connQueue ~= connection;
|
||||||
|
|
||||||
|
/* Unlock the queue */
|
||||||
|
connQueueLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
|
|
Loading…
Reference in New Issue