ThreadedSocketService

A gio.threaded_socket_service.ThreadedSocketService is a simple subclass of gio.socket_service.SocketService that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the gio.threaded_socket_service.ThreadedSocketService.run in the new thread.

The signal handler may perform blocking I/O and need not return until the connection is closed.

The service is implemented using a thread pool, so there is a limited amount of threads available to serve incoming requests. The service automatically stops the gio.socket_service.SocketService from accepting new connections when all threads are busy.

As with gio.socket_service.SocketService, you may connect to gio.threaded_socket_service.ThreadedSocketService.run, or subclass and override the default handler.

Constructors

this
this(int maxThreads)

Creates a new #GThreadedSocketService with no listeners. Listeners must be added with one of the #GSocketListener "add" methods.

Members

Functions

connectRun
ulong connectRun(T callback, Flag!"After" after)

Connect to Run signal.

Inherited Members

From SocketService

isActive
bool isActive()

Check whether the service is active or not. An active service will accept new clients that connect, while a non-active service will let connecting clients queue up until the service is started.

start
void start()

Restarts the service, i.e. start accepting connections from the added sockets when the mainloop runs. This only needs to be called after the service has been stopped from gio.socket_service.SocketService.stop.

stop
void stop()

Stops the service, i.e. stops accepting connections from the added sockets when the mainloop runs.

connectIncoming
ulong connectIncoming(T callback, Flag!"After" after)

Connect to Incoming signal.