{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A t'GI.Gio.Objects.ThreadedSocketService.ThreadedSocketService' is a simple subclass of t'GI.Gio.Objects.SocketService.SocketService'
-- that handles incoming connections by creating a worker thread and
-- dispatching the connection to it by emitting the
-- [ThreadedSocketService::run]("GI.Gio.Objects.ThreadedSocketService#g:signal: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 t'GI.Gio.Objects.SocketService.SocketService' from accepting
-- new connections when all threads are busy.
-- 
-- As with t'GI.Gio.Objects.SocketService.SocketService', you may connect to [ThreadedSocketService::run]("GI.Gio.Objects.ThreadedSocketService#g:signal:run"),
-- or subclass and override the default handler.
-- 
-- /Since: 2.22/

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gio.Objects.ThreadedSocketService
    ( 

-- * Exported types
    ThreadedSocketService(..)               ,
    IsThreadedSocketService                 ,
    toThreadedSocketService                 ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [accept]("GI.Gio.Objects.SocketListener#g:method:accept"), [acceptAsync]("GI.Gio.Objects.SocketListener#g:method:acceptAsync"), [acceptFinish]("GI.Gio.Objects.SocketListener#g:method:acceptFinish"), [acceptSocket]("GI.Gio.Objects.SocketListener#g:method:acceptSocket"), [acceptSocketAsync]("GI.Gio.Objects.SocketListener#g:method:acceptSocketAsync"), [acceptSocketFinish]("GI.Gio.Objects.SocketListener#g:method:acceptSocketFinish"), [addAddress]("GI.Gio.Objects.SocketListener#g:method:addAddress"), [addAnyInetPort]("GI.Gio.Objects.SocketListener#g:method:addAnyInetPort"), [addInetPort]("GI.Gio.Objects.SocketListener#g:method:addInetPort"), [addSocket]("GI.Gio.Objects.SocketListener#g:method:addSocket"), [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [close]("GI.Gio.Objects.SocketListener#g:method:close"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isActive]("GI.Gio.Objects.SocketService#g:method:isActive"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [start]("GI.Gio.Objects.SocketService#g:method:start"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [stop]("GI.Gio.Objects.SocketService#g:method:stop"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
-- 
-- ==== Setters
-- [setBacklog]("GI.Gio.Objects.SocketListener#g:method:setBacklog"), [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveThreadedSocketServiceMethod      ,
#endif

-- ** new #method:new#

    threadedSocketServiceNew                ,




 -- * Properties


-- ** maxThreads #attr:maxThreads#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    ThreadedSocketServiceMaxThreadsPropertyInfo,
#endif
    constructThreadedSocketServiceMaxThreads,
    getThreadedSocketServiceMaxThreads      ,
#if defined(ENABLE_OVERLOADING)
    threadedSocketServiceMaxThreads         ,
#endif




 -- * Signals


-- ** run #signal:run#

    ThreadedSocketServiceRunCallback        ,
#if defined(ENABLE_OVERLOADING)
    ThreadedSocketServiceRunSignalInfo      ,
#endif
    afterThreadedSocketServiceRun           ,
    onThreadedSocketServiceRun              ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketConnection as Gio.SocketConnection
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketListener as Gio.SocketListener
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketService as Gio.SocketService

-- | Memory-managed wrapper type.
newtype ThreadedSocketService = ThreadedSocketService (SP.ManagedPtr ThreadedSocketService)
    deriving (ThreadedSocketService -> ThreadedSocketService -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThreadedSocketService -> ThreadedSocketService -> Bool
$c/= :: ThreadedSocketService -> ThreadedSocketService -> Bool
== :: ThreadedSocketService -> ThreadedSocketService -> Bool
$c== :: ThreadedSocketService -> ThreadedSocketService -> Bool
Eq)

instance SP.ManagedPtrNewtype ThreadedSocketService where
    toManagedPtr :: ThreadedSocketService -> ManagedPtr ThreadedSocketService
toManagedPtr (ThreadedSocketService ManagedPtr ThreadedSocketService
p) = ManagedPtr ThreadedSocketService
p

foreign import ccall "g_threaded_socket_service_get_type"
    c_g_threaded_socket_service_get_type :: IO B.Types.GType

instance B.Types.TypedObject ThreadedSocketService where
    glibType :: IO GType
glibType = IO GType
c_g_threaded_socket_service_get_type

instance B.Types.GObject ThreadedSocketService

-- | Type class for types which can be safely cast to `ThreadedSocketService`, for instance with `toThreadedSocketService`.
class (SP.GObject o, O.IsDescendantOf ThreadedSocketService o) => IsThreadedSocketService o
instance (SP.GObject o, O.IsDescendantOf ThreadedSocketService o) => IsThreadedSocketService o

instance O.HasParentTypes ThreadedSocketService
type instance O.ParentTypes ThreadedSocketService = '[Gio.SocketService.SocketService, Gio.SocketListener.SocketListener, GObject.Object.Object]

-- | Cast to `ThreadedSocketService`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toThreadedSocketService :: (MIO.MonadIO m, IsThreadedSocketService o) => o -> m ThreadedSocketService
toThreadedSocketService :: forall (m :: * -> *) o.
(MonadIO m, IsThreadedSocketService o) =>
o -> m ThreadedSocketService
toThreadedSocketService = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr ThreadedSocketService -> ThreadedSocketService
ThreadedSocketService

-- | Convert 'ThreadedSocketService' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe ThreadedSocketService) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_threaded_socket_service_get_type
    gvalueSet_ :: Ptr GValue -> Maybe ThreadedSocketService -> IO ()
gvalueSet_ Ptr GValue
gv Maybe ThreadedSocketService
P.Nothing = forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (forall a. Ptr a
FP.nullPtr :: FP.Ptr ThreadedSocketService)
    gvalueSet_ Ptr GValue
gv (P.Just ThreadedSocketService
obj) = forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ThreadedSocketService
obj (forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe ThreadedSocketService)
gvalueGet_ Ptr GValue
gv = do
        Ptr ThreadedSocketService
ptr <- forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr ThreadedSocketService)
        if Ptr ThreadedSocketService
ptr forall a. Eq a => a -> a -> Bool
/= forall a. Ptr a
FP.nullPtr
        then forall a. a -> Maybe a
P.Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr ThreadedSocketService -> ThreadedSocketService
ThreadedSocketService Ptr ThreadedSocketService
ptr
        else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveThreadedSocketServiceMethod (t :: Symbol) (o :: *) :: * where
    ResolveThreadedSocketServiceMethod "accept" o = Gio.SocketListener.SocketListenerAcceptMethodInfo
    ResolveThreadedSocketServiceMethod "acceptAsync" o = Gio.SocketListener.SocketListenerAcceptAsyncMethodInfo
    ResolveThreadedSocketServiceMethod "acceptFinish" o = Gio.SocketListener.SocketListenerAcceptFinishMethodInfo
    ResolveThreadedSocketServiceMethod "acceptSocket" o = Gio.SocketListener.SocketListenerAcceptSocketMethodInfo
    ResolveThreadedSocketServiceMethod "acceptSocketAsync" o = Gio.SocketListener.SocketListenerAcceptSocketAsyncMethodInfo
    ResolveThreadedSocketServiceMethod "acceptSocketFinish" o = Gio.SocketListener.SocketListenerAcceptSocketFinishMethodInfo
    ResolveThreadedSocketServiceMethod "addAddress" o = Gio.SocketListener.SocketListenerAddAddressMethodInfo
    ResolveThreadedSocketServiceMethod "addAnyInetPort" o = Gio.SocketListener.SocketListenerAddAnyInetPortMethodInfo
    ResolveThreadedSocketServiceMethod "addInetPort" o = Gio.SocketListener.SocketListenerAddInetPortMethodInfo
    ResolveThreadedSocketServiceMethod "addSocket" o = Gio.SocketListener.SocketListenerAddSocketMethodInfo
    ResolveThreadedSocketServiceMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveThreadedSocketServiceMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveThreadedSocketServiceMethod "close" o = Gio.SocketListener.SocketListenerCloseMethodInfo
    ResolveThreadedSocketServiceMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveThreadedSocketServiceMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveThreadedSocketServiceMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveThreadedSocketServiceMethod "isActive" o = Gio.SocketService.SocketServiceIsActiveMethodInfo
    ResolveThreadedSocketServiceMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveThreadedSocketServiceMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveThreadedSocketServiceMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveThreadedSocketServiceMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveThreadedSocketServiceMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveThreadedSocketServiceMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveThreadedSocketServiceMethod "start" o = Gio.SocketService.SocketServiceStartMethodInfo
    ResolveThreadedSocketServiceMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveThreadedSocketServiceMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveThreadedSocketServiceMethod "stop" o = Gio.SocketService.SocketServiceStopMethodInfo
    ResolveThreadedSocketServiceMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveThreadedSocketServiceMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveThreadedSocketServiceMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveThreadedSocketServiceMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveThreadedSocketServiceMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveThreadedSocketServiceMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveThreadedSocketServiceMethod "setBacklog" o = Gio.SocketListener.SocketListenerSetBacklogMethodInfo
    ResolveThreadedSocketServiceMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveThreadedSocketServiceMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveThreadedSocketServiceMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveThreadedSocketServiceMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveThreadedSocketServiceMethod t ThreadedSocketService, O.OverloadedMethod info ThreadedSocketService p) => OL.IsLabel t (ThreadedSocketService -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveThreadedSocketServiceMethod t ThreadedSocketService, O.OverloadedMethod info ThreadedSocketService p, R.HasField t ThreadedSocketService p) => R.HasField t ThreadedSocketService p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveThreadedSocketServiceMethod t ThreadedSocketService, O.OverloadedMethodInfo info ThreadedSocketService) => OL.IsLabel t (O.MethodProxy info ThreadedSocketService) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

-- signal ThreadedSocketService::run
-- | The [run](#g: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.
type ThreadedSocketServiceRunCallback =
    Gio.SocketConnection.SocketConnection
    -- ^ /@connection@/: a new t'GI.Gio.Objects.SocketConnection.SocketConnection' object.
    -> Maybe GObject.Object.Object
    -- ^ /@sourceObject@/: the source_object passed to 'GI.Gio.Objects.SocketListener.socketListenerAddAddress'.
    -> IO Bool
    -- ^ __Returns:__ 'P.True' to stop further signal handlers from being called

type C_ThreadedSocketServiceRunCallback =
    Ptr ThreadedSocketService ->            -- object
    Ptr Gio.SocketConnection.SocketConnection ->
    Ptr GObject.Object.Object ->
    Ptr () ->                               -- user_data
    IO CInt

-- | Generate a function pointer callable from C code, from a `C_ThreadedSocketServiceRunCallback`.
foreign import ccall "wrapper"
    mk_ThreadedSocketServiceRunCallback :: C_ThreadedSocketServiceRunCallback -> IO (FunPtr C_ThreadedSocketServiceRunCallback)

wrap_ThreadedSocketServiceRunCallback :: 
    GObject a => (a -> ThreadedSocketServiceRunCallback) ->
    C_ThreadedSocketServiceRunCallback
wrap_ThreadedSocketServiceRunCallback :: forall a.
GObject a =>
(a -> ThreadedSocketServiceRunCallback)
-> C_ThreadedSocketServiceRunCallback
wrap_ThreadedSocketServiceRunCallback a -> ThreadedSocketServiceRunCallback
gi'cb Ptr ThreadedSocketService
gi'selfPtr Ptr SocketConnection
connection Ptr Object
sourceObject Ptr ()
_ = do
    SocketConnection
connection' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr SocketConnection -> SocketConnection
Gio.SocketConnection.SocketConnection) Ptr SocketConnection
connection
    Maybe Object
maybeSourceObject <-
        if Ptr Object
sourceObject forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr
        then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
        else do
            Object
sourceObject' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Object -> Object
GObject.Object.Object) Ptr Object
sourceObject
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just Object
sourceObject'
    Bool
result <- forall a b.
(HasCallStack, ManagedPtrNewtype a) =>
Ptr a -> (a -> IO b) -> IO b
B.ManagedPtr.withTransient Ptr ThreadedSocketService
gi'selfPtr forall a b. (a -> b) -> a -> b
$ \ThreadedSocketService
gi'self -> a -> ThreadedSocketServiceRunCallback
gi'cb (coerce :: forall a b. Coercible a b => a -> b
Coerce.coerce ThreadedSocketService
gi'self)  SocketConnection
connection' Maybe Object
maybeSourceObject
    let result' :: CInt
result' = (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Enum a => a -> Int
fromEnum) Bool
result
    forall (m :: * -> *) a. Monad m => a -> m a
return CInt
result'


-- | Connect a signal handler for the [run](#signal:run) signal, to be run before the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.on' threadedSocketService #run callback
-- @
-- 
-- 
onThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId
onThreadedSocketServiceRun :: forall a (m :: * -> *).
(IsThreadedSocketService a, MonadIO m) =>
a
-> ((?self::a) => ThreadedSocketServiceRunCallback)
-> m SignalHandlerId
onThreadedSocketServiceRun a
obj (?self::a) => ThreadedSocketServiceRunCallback
cb = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
    let wrapped :: a -> ThreadedSocketServiceRunCallback
wrapped a
self = let ?self = a
self in (?self::a) => ThreadedSocketServiceRunCallback
cb
    let wrapped' :: C_ThreadedSocketServiceRunCallback
wrapped' = forall a.
GObject a =>
(a -> ThreadedSocketServiceRunCallback)
-> C_ThreadedSocketServiceRunCallback
wrap_ThreadedSocketServiceRunCallback a -> ThreadedSocketServiceRunCallback
wrapped
    FunPtr C_ThreadedSocketServiceRunCallback
wrapped'' <- C_ThreadedSocketServiceRunCallback
-> IO (FunPtr C_ThreadedSocketServiceRunCallback)
mk_ThreadedSocketServiceRunCallback C_ThreadedSocketServiceRunCallback
wrapped'
    forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"run" FunPtr C_ThreadedSocketServiceRunCallback
wrapped'' SignalConnectMode
SignalConnectBefore forall a. Maybe a
Nothing

-- | Connect a signal handler for the [run](#signal:run) signal, to be run after the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.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.
-- 
afterThreadedSocketServiceRun :: (IsThreadedSocketService a, MonadIO m) => a -> ((?self :: a) => ThreadedSocketServiceRunCallback) -> m SignalHandlerId
afterThreadedSocketServiceRun :: forall a (m :: * -> *).
(IsThreadedSocketService a, MonadIO m) =>
a
-> ((?self::a) => ThreadedSocketServiceRunCallback)
-> m SignalHandlerId
afterThreadedSocketServiceRun a
obj (?self::a) => ThreadedSocketServiceRunCallback
cb = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
    let wrapped :: a -> ThreadedSocketServiceRunCallback
wrapped a
self = let ?self = a
self in (?self::a) => ThreadedSocketServiceRunCallback
cb
    let wrapped' :: C_ThreadedSocketServiceRunCallback
wrapped' = forall a.
GObject a =>
(a -> ThreadedSocketServiceRunCallback)
-> C_ThreadedSocketServiceRunCallback
wrap_ThreadedSocketServiceRunCallback a -> ThreadedSocketServiceRunCallback
wrapped
    FunPtr C_ThreadedSocketServiceRunCallback
wrapped'' <- C_ThreadedSocketServiceRunCallback
-> IO (FunPtr C_ThreadedSocketServiceRunCallback)
mk_ThreadedSocketServiceRunCallback C_ThreadedSocketServiceRunCallback
wrapped'
    forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"run" FunPtr C_ThreadedSocketServiceRunCallback
wrapped'' SignalConnectMode
SignalConnectAfter forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data ThreadedSocketServiceRunSignalInfo
instance SignalInfo ThreadedSocketServiceRunSignalInfo where
    type HaskellCallbackType ThreadedSocketServiceRunSignalInfo = ThreadedSocketServiceRunCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_ThreadedSocketServiceRunCallback cb
        cb'' <- mk_ThreadedSocketServiceRunCallback cb'
        connectSignalFunPtr obj "run" cb'' connectMode detail
    dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Objects.ThreadedSocketService::run"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Objects-ThreadedSocketService.html#g:signal:run"})

#endif

-- VVV Prop "max-threads"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@max-threads@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' threadedSocketService #maxThreads
-- @
getThreadedSocketServiceMaxThreads :: (MonadIO m, IsThreadedSocketService o) => o -> m Int32
getThreadedSocketServiceMaxThreads :: forall (m :: * -> *) o.
(MonadIO m, IsThreadedSocketService o) =>
o -> m Int32
getThreadedSocketServiceMaxThreads o
obj = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ forall a. GObject a => a -> String -> IO Int32
B.Properties.getObjectPropertyInt32 o
obj String
"max-threads"

-- | Construct a `GValueConstruct` with valid value for the “@max-threads@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructThreadedSocketServiceMaxThreads :: (IsThreadedSocketService o, MIO.MonadIO m) => Int32 -> m (GValueConstruct o)
constructThreadedSocketServiceMaxThreads :: forall o (m :: * -> *).
(IsThreadedSocketService o, MonadIO m) =>
Int32 -> m (GValueConstruct o)
constructThreadedSocketServiceMaxThreads Int32
val = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ do
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ forall o. String -> Int32 -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyInt32 String
"max-threads" Int32
val

#if defined(ENABLE_OVERLOADING)
data ThreadedSocketServiceMaxThreadsPropertyInfo
instance AttrInfo ThreadedSocketServiceMaxThreadsPropertyInfo where
    type AttrAllowedOps ThreadedSocketServiceMaxThreadsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint ThreadedSocketServiceMaxThreadsPropertyInfo = IsThreadedSocketService
    type AttrSetTypeConstraint ThreadedSocketServiceMaxThreadsPropertyInfo = (~) Int32
    type AttrTransferTypeConstraint ThreadedSocketServiceMaxThreadsPropertyInfo = (~) Int32
    type AttrTransferType ThreadedSocketServiceMaxThreadsPropertyInfo = Int32
    type AttrGetType ThreadedSocketServiceMaxThreadsPropertyInfo = Int32
    type AttrLabel ThreadedSocketServiceMaxThreadsPropertyInfo = "max-threads"
    type AttrOrigin ThreadedSocketServiceMaxThreadsPropertyInfo = ThreadedSocketService
    attrGet = getThreadedSocketServiceMaxThreads
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructThreadedSocketServiceMaxThreads
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gio.Objects.ThreadedSocketService.maxThreads"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.30/docs/GI-Gio-Objects-ThreadedSocketService.html#g:attr:maxThreads"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ThreadedSocketService
type instance O.AttributeList ThreadedSocketService = ThreadedSocketServiceAttributeList
type ThreadedSocketServiceAttributeList = ('[ '("active", Gio.SocketService.SocketServiceActivePropertyInfo), '("listenBacklog", Gio.SocketListener.SocketListenerListenBacklogPropertyInfo), '("maxThreads", ThreadedSocketServiceMaxThreadsPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
threadedSocketServiceMaxThreads :: AttrLabelProxy "maxThreads"
threadedSocketServiceMaxThreads = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ThreadedSocketService = ThreadedSocketServiceSignalList
type ThreadedSocketServiceSignalList = ('[ '("event", Gio.SocketListener.SocketListenerEventSignalInfo), '("incoming", Gio.SocketService.SocketServiceIncomingSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("run", ThreadedSocketServiceRunSignalInfo)] :: [(Symbol, *)])

#endif

-- method ThreadedSocketService::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "max_threads"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the maximal number of threads to execute concurrently\n  handling incoming clients, -1 means no limit"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "ThreadedSocketService" })
-- throws : False
-- Skip return : False

foreign import ccall "g_threaded_socket_service_new" g_threaded_socket_service_new :: 
    Int32 ->                                -- max_threads : TBasicType TInt
    IO (Ptr ThreadedSocketService)

-- | Creates a new t'GI.Gio.Objects.ThreadedSocketService.ThreadedSocketService' with no listeners. Listeners
-- must be added with one of the t'GI.Gio.Objects.SocketListener.SocketListener' \"add\" methods.
-- 
-- /Since: 2.22/
threadedSocketServiceNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    -- ^ /@maxThreads@/: the maximal number of threads to execute concurrently
    --   handling incoming clients, -1 means no limit
    -> m ThreadedSocketService
    -- ^ __Returns:__ a new t'GI.Gio.Objects.SocketService.SocketService'.
threadedSocketServiceNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Int32 -> m ThreadedSocketService
threadedSocketServiceNew Int32
maxThreads = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
    Ptr ThreadedSocketService
result <- Int32 -> IO (Ptr ThreadedSocketService)
g_threaded_socket_service_new Int32
maxThreads
    forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"threadedSocketServiceNew" Ptr ThreadedSocketService
result
    ThreadedSocketService
result' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr ThreadedSocketService -> ThreadedSocketService
ThreadedSocketService) Ptr ThreadedSocketService
result
    forall (m :: * -> *) a. Monad m => a -> m a
return ThreadedSocketService
result'

#if defined(ENABLE_OVERLOADING)
#endif