glibmm 2.31.20
|
A threaded GSocketService. More...
#include <giomm/threadedsocketservice.h>
Public Member Functions | |
virtual | ~ThreadedSocketService () |
GThreadedSocketService* | gobj () |
Provides access to the underlying C GObject. | |
const GThreadedSocketService* | gobj () const |
Provides access to the underlying C GObject. | |
GThreadedSocketService* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Glib::SignalProxy2< bool, const Glib::RefPtr < SocketConnection >&, const Glib::RefPtr< Glib::Object >& > | signal_run () |
Glib::PropertyProxy_ReadOnly< int > | property_max_threads () const |
You rarely need to use properties because there are get_ and set_ methods for almost all of them. | |
Static Public Member Functions | |
static Glib::RefPtr < ThreadedSocketService > | create (int max_threads) |
Protected Member Functions | |
ThreadedSocketService (int max_threads) | |
virtual bool | on_run (const Glib::RefPtr< SocketConnection >& connection, const Glib::RefPtr< Glib::Object >& source_object) |
This is a default handler for the signal signal_run(). | |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr < Gio::ThreadedSocketService > | wrap (GThreadedSocketService* object, bool take_copy=false) |
A Glib::wrap() method for this object. |
A threaded GSocketService.
A ThreadedSocketService is a simple subclass of 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 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 availible to serve incomming requests. The service automatically stops the SocketService from accepting new connections when all threads are busy.
As with SocketService, you may connect to ThreadedSocketService:run, or subclass and override the default handler.
virtual Gio::ThreadedSocketService::~ThreadedSocketService | ( | ) | [virtual] |
Gio::ThreadedSocketService::ThreadedSocketService | ( | int | max_threads | ) | [explicit, protected] |
static Glib::RefPtr<ThreadedSocketService> Gio::ThreadedSocketService::create | ( | int | max_threads | ) | [static] |
GThreadedSocketService* Gio::ThreadedSocketService::gobj | ( | ) | [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gio::SocketService.
const GThreadedSocketService* Gio::ThreadedSocketService::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gio::SocketService.
GThreadedSocketService* Gio::ThreadedSocketService::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Reimplemented from Gio::SocketService.
virtual bool Gio::ThreadedSocketService::on_run | ( | const Glib::RefPtr< SocketConnection >& | connection, |
const Glib::RefPtr< Glib::Object >& | source_object | ||
) | [protected, virtual] |
This is a default handler for the signal signal_run().
Glib::PropertyProxy_ReadOnly< int > Gio::ThreadedSocketService::property_max_threads | ( | ) | const |
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::SignalProxy2< bool,const Glib::RefPtr<SocketConnection>&,const Glib::RefPtr<Glib::Object>& > Gio::ThreadedSocketService::signal_run | ( | ) |
bool on_my_run(const Glib::RefPtr<SocketConnection>& connection, const Glib::RefPtr<Glib::Object>& source_object)
The signal_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.
connection | A new SocketConnection object. |
source_object | The source_object passed to g_socket_listener_add_address(). |
true
to stop further signal handlers from being called. Glib::RefPtr< Gio::ThreadedSocketService > wrap | ( | GThreadedSocketService * | object, |
bool | take_copy = false |
||
) | [related] |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |