ThreadedSocketService

A GThreadedSocketService is a simple subclass of GSocketService that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the "run" signal in the new thread.

The signal handler may perform blocking IO 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 GSocketService from accepting new connections when all threads are busy.

As with GSocketService, you may connect to "run", or subclass and override the default handler.

Constructors

this
this(GThreadedSocketService* gThreadedSocketService)

Sets our main struct and passes it to the parent class

this
this(int maxThreads)

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

Members

Functions

addOnRun
void addOnRun(bool delegate(GSocketConnection*, GObject*, ThreadedSocketService) dlg, ConnectFlags connectFlags)

The ::run signal is emitted in a worker thread in response to an incoming connection. This thread is dedicated to handling connection and may perform blocking IO. The signal handler need not return until the connection is closed. TRUE to stop further signal handlers from being called See Also GSocketService.

getStruct
void* getStruct()

the main Gtk struct as a void*

getThreadedSocketServiceStruct
GThreadedSocketService* getThreadedSocketServiceStruct()

Get the main Gtk struct

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

callBackRun
gboolean callBackRun(GThreadedSocketService* serviceStruct, GSocketConnection* connection, GObject* sourceObject, ThreadedSocketService _threadedSocketService)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gThreadedSocketService
GThreadedSocketService* gThreadedSocketService;

the main Gtk struct

onRunListeners
bool delegate(GSocketConnection*, GObject*, ThreadedSocketService)[] onRunListeners;
Undocumented in source.

Inherited Members

From SocketService

gSocketService
GSocketService* gSocketService;

the main Gtk struct

getSocketServiceStruct
GSocketService* getSocketServiceStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
connectedSignals
int[string] connectedSignals;
onIncomingListeners
bool delegate(GSocketConnection*, GObject*, SocketService)[] onIncomingListeners;
Undocumented in source.
addOnIncoming
void addOnIncoming(bool delegate(GSocketConnection*, GObject*, SocketService) dlg, ConnectFlags connectFlags)

The ::incoming signal is emitted when a new incoming connection to service needs to be handled. The handler must initiate the handling of connection, but may not block; in essence, asynchronous operations must be used. connection will be unreffed once the signal handler returns, so you need to ref it yourself if you are planning to use it. TRUE to stop other handlers from being called Since 2.22 See Also GThreadedSocketService, GSocketListener.

callBackIncoming
gboolean callBackIncoming(GSocketService* serviceStruct, GSocketConnection* connection, GObject* sourceObject, SocketService _socketService)
Undocumented in source. Be warned that the author may not have intended to support it.
start
void start()

Starts the service, i.e. start accepting connections from the added sockets when the mainloop runs. This call is thread-safe, so it may be called from a thread handling an incoming client request. Since 2.22

stop
void stop()

Stops the service, i.e. stops accepting connections from the added sockets when the mainloop runs. This call is thread-safe, so it may be called from a thread handling an incoming client request. Since 2.22

isActive
int 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. Since 2.22 Signal Details The "incoming" signal gboolean user_function (GSocketService *service, GSocketConnection *connection, GObject *source_object, gpointer user_data) : Run Last The ::incoming signal is emitted when a new incoming connection to service needs to be handled. The handler must initiate the handling of connection, but may not block; in essence, asynchronous operations must be used. connection will be unreffed once the signal handler returns, so you need to ref it yourself if you are planning to use it. Since 2.22

Meta