A threaded GSocketService. More...
Inherits Gio::SocketService.
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 |
The max number of threads handling clients for this service. | |
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) |
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] |
const GThreadedSocketService* Gio::ThreadedSocketService::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gio::SocketService.
GThreadedSocketService* Gio::ThreadedSocketService::gobj | ( | ) | [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] |
Glib::PropertyProxy_ReadOnly<int> Gio::ThreadedSocketService::property_max_threads | ( | ) | const |
The max number of threads handling clients for this service.
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)
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. |