/* Copyright (C) 2010 Jonathon Jongsma
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include
_DEFS(giomm,gio)
_PINCLUDE(giomm/private/socketservice_p.h)
namespace Gio
{
/**
* 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::signal_run(),
* or subclass and override the default handler.
*
* @newin{2,24}
* @ingroup NetworkIO
*/
class GIOMM_API ThreadedSocketService : public Gio::SocketService
{
_CLASS_GOBJECT(ThreadedSocketService, GThreadedSocketService, G_THREADED_SOCKET_SERVICE, Gio::SocketService, GSocketService, , , GIOMM_API)
protected:
_WRAP_CTOR(ThreadedSocketService(int max_threads), g_threaded_socket_service_new)
public:
_WRAP_CREATE(int max_threads)
#m4 _CONVERSION(`GObject*',`const Glib::RefPtr&',`Glib::wrap($3, true)')
#m4 _CONVERSION(`GSocketConnection*',`const Glib::RefPtr&',`Glib::wrap($3, true)')
_WRAP_SIGNAL(bool run(const Glib::RefPtr& connection, const Glib::RefPtr& source_object), "run")
_WRAP_PROPERTY("max-threads", int)
};
} // namespace Gio