Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

GLib::ThreadedSocketService

class GLib::ThreadedSocketService

A GLib::ThreadedSocketService is a simple subclass of GLib::SocketService 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 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 availible to serve incomming requests. The service automatically stops the GLib::SocketService from accepting new connections when all threads are busy.

As with GLib::SocketService, you may connect to “run”, or subclass and override the default handler.

Class Methods

GLib::ThreadedSocketService.new(max_threads = 10)
Creates a new GThreadedSocketService with no listeners. Listeners must be added with Glib::SocketService#add_listeners.
  • max_threads: the maximum number of threads to execute, concurrently handling incoming clients (-1 for no limit)
  • Returns: a new GLib::ThreadedSocketService

Instance Methods

max_threads
Gets the maximum number of threads handling clients for this service.
  • Returns: The maximum number of threads handling clients for this service

Properties

max-threads: Integer (Read/Write)

The maximum number of threads handling clients for this service

Allowed values: ≥ 0

Default value: 10

Signals

run: self, connection, source_object
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.
Last modified:2010/12/27 21:59:23
Keyword(s):
References:[index-ruby-glib2] [Ruby/GIO] [index-ruby-gio2] [GLib::SocketListener] [GLib::SocketService] [GLib::ThreadedSocketService]