Package ch.bailu.gtk.gio
Class ThreadedSocketService
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.gio.SocketListener
ch.bailu.gtk.gio.SocketService
ch.bailu.gtk.gio.ThreadedSocketService
- All Implemented Interfaces:
PointerInterface
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
#GThreadedSocketService::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 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 #GThreadedSocketService::run,
or subclass and override the default handler.
that handles incoming connections by creating a worker thread and
dispatching the connection to it by emitting the
#GThreadedSocketService::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 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 #GThreadedSocketService::run,
or subclass and override the default handler.
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gio.SocketService
SocketService.OnIncoming
Nested classes/interfaces inherited from class ch.bailu.gtk.gio.SocketListener
SocketListener.OnAsyncReadyCallback, SocketListener.OnEvent
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gio.SocketService
SIGNAL_ON_INCOMING
Fields inherited from class ch.bailu.gtk.gio.SocketListener
SIGNAL_ON_EVENT
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionThreadedSocketService
(int max_threads) Creates a new #GThreadedSocketService with no listeners.ThreadedSocketService
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassHandler
static int
static long
static TypeSystem.TypeSize
static long
static TypeSystem.TypeSize
onRun
(ThreadedSocketService.OnRun signal) Connect to signal "run".Methods inherited from class ch.bailu.gtk.gio.SocketService
isActive, onIncoming, start, stop
Methods inherited from class ch.bailu.gtk.gio.SocketListener
acceptAsync, acceptSocketAsync, addAnyInetPort, addInetPort, addSocket, close, onEvent, setBacklog
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_RUN
- See Also:
-
-
Constructor Details
-
ThreadedSocketService
-
ThreadedSocketService
public ThreadedSocketService(int max_threads) Creates a new #GThreadedSocketService with no listeners. Listeners
must be added with one of the #GSocketListener "add" methods.- Parameters:
max_threads
- the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit
-
-
Method Details
-
getClassHandler
-
onRun
Connect to signal "run".
SeeThreadedSocketService.OnRun.onRun(ch.bailu.gtk.gio.SocketConnection, ch.bailu.gtk.gobject.Object)
for signal description.
FieldSIGNAL_ON_RUN
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-