1.93 <GThreadedSocketService>

Class: <GThreadedSocketService>

It derives from <GSocketService>.

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 [signal@Gio.ThreadedSocketService::run signal] 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 <GSocketService> from accepting new connections when all threads are busy.

As with <GSocketService>, you may connect to threaded-socket-service:run, or subclass and override the default handler.

Fields

parent-instance
priv

Properties

Property: threaded-socket-service:max-threads self

The maximum number of threads handling clients for this service.

Its value is a 32-bit integer.

It can only be set when the object is made, with #:max-threads.

Procedures

Procedure: threaded-socket-service:new max-threads ⇒ %return

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

max-threads

Passed: a 32-bit integer.

the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit

%return

Returned: a <GSocketService>.

a new <GSocketService>.

Signals

Signal: threaded-socket-service:run

Connect a handler with (connect object threaded-socket-service:run handler). It is called as (handler self connection source-object) ⇒ %return.

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.

self

Passed: a <GThreadedSocketService>.

connection

Passed: a <GSocketConnection>.

a new <GSocketConnection> object.

source-object

Passed: a <GObject>, or #f.

the source_object passed to socket-listener:add-address.

%return

Returned: a boolean.

#t to stop further signal handlers from being called

Virtual methods

Virtual method: threaded-socket-service:do-run implementor self connection source-object ⇒ %return

To override it in a new class, give register-type #:vfuncs `((run . ,procedure)). The procedure is called as (procedure self connection source-object) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GThreadedSocketService>, or a class that derives from it, or its GType number.

self

Passed: a <GThreadedSocketService>.

connection

Passed: a <GSocketConnection>.

source-object

Passed: a <GObject>.

%return

Returned: a boolean.