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 #GThreadedSocketService::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 #GThreadedSocketService::run, or subclass and override the default handler.

Constructors

this
this(GThreadedSocketService* gThreadedSocketService, bool ownedRef)

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.

Members

Classes

OnRunDelegateWrapper
class OnRunDelegateWrapper
Undocumented in source.

Functions

addOnRun
gulong addOnRun(bool delegate(SocketConnection, ObjectG, 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.

getStruct
void* getStruct()

the main Gtk struct as a void*

getThreadedSocketServiceStruct
GThreadedSocketService* getThreadedSocketServiceStruct()

Get the main Gtk struct

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

Static functions

callBackRun
int callBackRun(GThreadedSocketService* threadedsocketserviceStruct, GSocketConnection* connection, GObject* sourceObject, OnRunDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackRunDestroy
void callBackRunDestroy(OnRunDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
getType
GType getType()

Variables

gThreadedSocketService
GThreadedSocketService* gThreadedSocketService;

the main Gtk struct

onRunListeners
OnRunDelegateWrapper[] 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.
getType
GType getType()
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 g_socket_service_stop().

stop
void stop()

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

OnIncomingDelegateWrapper
class OnIncomingDelegateWrapper
Undocumented in source.
onIncomingListeners
OnIncomingDelegateWrapper[] onIncomingListeners;
Undocumented in source.
addOnIncoming
gulong addOnIncoming(bool delegate(SocketConnection, ObjectG, 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.

callBackIncoming
int callBackIncoming(GSocketService* socketserviceStruct, GSocketConnection* connection, GObject* sourceObject, OnIncomingDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackIncomingDestroy
void callBackIncomingDestroy(OnIncomingDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
internalRemoveOnIncoming
void internalRemoveOnIncoming(OnIncomingDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta

Since

2.22