Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
A GThreadedSocketService
is a simple subclass of SocketService
that handles incoming connections by creating a worker thread and
dispatching the connection to it by emitting the
signalgio
.ThreadedSocketService[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 available to serve incoming 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.
Since: 2.22
Synopsis
- newtype ThreadedSocketService = ThreadedSocketService (ManagedPtr ThreadedSocketService)
- class (GObject o, IsDescendantOf ThreadedSocketService o) => IsThreadedSocketService o
- toThreadedSocketService :: (MonadIO m, IsThreadedSocketService o) => o -> m ThreadedSocketService
- threadedSocketServiceNew :: (HasCallStack, MonadIO m) => Int32 -> m ThreadedSocketService
- constructThreadedSocketServiceMaxThreads :: (IsThreadedSocketService o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getThreadedSocketServiceMaxThreads :: (MonadIO m, IsThreadedSocketService o) => o -> m Int32
- type ThreadedSocketServiceRunCallback = SocketConnection -> Maybe Object -> IO Bool
- afterThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId
- onThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId
Exported types
newtype ThreadedSocketService Source #
Memory-managed wrapper type.
Instances
Eq ThreadedSocketService Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService (==) :: ThreadedSocketService -> ThreadedSocketService -> Bool # (/=) :: ThreadedSocketService -> ThreadedSocketService -> Bool # | |
GObject ThreadedSocketService Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService | |
ManagedPtrNewtype ThreadedSocketService Source # | |
TypedObject ThreadedSocketService Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService | |
HasParentTypes ThreadedSocketService Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService | |
IsGValue (Maybe ThreadedSocketService) Source # | Convert |
Defined in GI.Gio.Objects.ThreadedSocketService gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe ThreadedSocketService -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe ThreadedSocketService) # | |
type ParentTypes ThreadedSocketService Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService |
class (GObject o, IsDescendantOf ThreadedSocketService o) => IsThreadedSocketService o Source #
Type class for types which can be safely cast to ThreadedSocketService
, for instance with toThreadedSocketService
.
Instances
(GObject o, IsDescendantOf ThreadedSocketService o) => IsThreadedSocketService o Source # | |
Defined in GI.Gio.Objects.ThreadedSocketService |
toThreadedSocketService :: (MonadIO m, IsThreadedSocketService o) => o -> m ThreadedSocketService Source #
Cast to ThreadedSocketService
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
accept, acceptAsync, acceptFinish, acceptSocket, acceptSocketAsync, acceptSocketFinish, addAddress, addAnyInetPort, addInetPort, addSocket, bindProperty, bindPropertyFull, close, forceFloating, freezeNotify, getv, isActive, isFloating, notify, notifyByPspec, ref, refSink, runDispose, start, stealData, stealQdata, stop, thawNotify, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
new
threadedSocketServiceNew Source #
:: (HasCallStack, MonadIO m) | |
=> Int32 |
|
-> m ThreadedSocketService | Returns: a new |
Creates a new ThreadedSocketService
with no listeners. Listeners
must be added with one of the SocketListener
"add" methods.
Since: 2.22
Properties
maxThreads
The maximum number of threads handling clients for this service.
Since: 2.22
constructThreadedSocketServiceMaxThreads :: (IsThreadedSocketService o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “max-threads
” property. This is rarely needed directly, but it is used by new
.
getThreadedSocketServiceMaxThreads :: (MonadIO m, IsThreadedSocketService o) => o -> m Int32 Source #
Get the value of the “max-threads
” property.
When overloading is enabled, this is equivalent to
get
threadedSocketService #maxThreads
Signals
run
type ThreadedSocketServiceRunCallback Source #
= SocketConnection |
|
-> Maybe Object |
|
-> IO Bool | Returns: |
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.
afterThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId Source #
Connect a signal handler for the run signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
threadedSocketService #run callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId Source #
Connect a signal handler for the run signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
threadedSocketService #run callback