guildenstern/epolldispatcher

This is an epoll-based dispatcher for platforms that support it, like Linux.

Servers are started by using the start proc.

This dispatcher delegates the thread scheduling to the operating system kernel, making it a rock solid dispatcher alternative. If your platform supports it, it is the recommended choice.

Procs

proc registerSocket(server: GuildenServer; socket: SocketHandle; flags = 0;
                    customdata: pointer = nil): bool {....raises: [],
    tags: [RootEffect], forbids: [].}
Add a socket whose read events will be then dispatched. Useful for servers operating in client mode.
proc start(server: GuildenServer; port: int; threadpoolsize: uint = 0): bool {.
    ...raises: [ResourceExhaustedError],
    tags: [ReadIOEffect, RootEffect, TimeEffect], forbids: [].}
Starts the server.thread loop, which then listens the given port for read requests until shuttingdown == true. Threadpoolsize means number of worker threads, but the name is kept for compatibility with the defautl dispatacher. By default threadpoolsize will be set to max(8, 2 * countProcessors()). If port number 0 is given, the server runs in client mode, where server.thread is not started, and sockets can be added manually using the registerSocket proc.