{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Structs.IOSchedulerJob
(
IOSchedulerJob(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveIOSchedulerJobMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
IOSchedulerJobSendToMainloopMethodInfo ,
#endif
iOSchedulerJobSendToMainloop ,
#if defined(ENABLE_OVERLOADING)
IOSchedulerJobSendToMainloopAsyncMethodInfo,
#endif
iOSchedulerJobSendToMainloopAsync ,
) 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.Kind as DK
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 Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
#else
import qualified GI.GLib.Callbacks as GLib.Callbacks
#endif
newtype IOSchedulerJob = IOSchedulerJob (SP.ManagedPtr IOSchedulerJob)
deriving (IOSchedulerJob -> IOSchedulerJob -> Bool
(IOSchedulerJob -> IOSchedulerJob -> Bool)
-> (IOSchedulerJob -> IOSchedulerJob -> Bool) -> Eq IOSchedulerJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IOSchedulerJob -> IOSchedulerJob -> Bool
== :: IOSchedulerJob -> IOSchedulerJob -> Bool
$c/= :: IOSchedulerJob -> IOSchedulerJob -> Bool
/= :: IOSchedulerJob -> IOSchedulerJob -> Bool
Eq)
instance SP.ManagedPtrNewtype IOSchedulerJob where
toManagedPtr :: IOSchedulerJob -> ManagedPtr IOSchedulerJob
toManagedPtr (IOSchedulerJob ManagedPtr IOSchedulerJob
p) = ManagedPtr IOSchedulerJob
p
instance BoxedPtr IOSchedulerJob where
boxedPtrCopy :: IOSchedulerJob -> IO IOSchedulerJob
boxedPtrCopy = IOSchedulerJob -> IO IOSchedulerJob
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: IOSchedulerJob -> IO ()
boxedPtrFree = \IOSchedulerJob
_x -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList IOSchedulerJob
type instance O.AttributeList IOSchedulerJob = IOSchedulerJobAttributeList
type IOSchedulerJobAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_io_scheduler_job_send_to_mainloop" g_io_scheduler_job_send_to_mainloop ::
Ptr IOSchedulerJob ->
FunPtr GLib.Callbacks.C_SourceFunc ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO CInt
{-# DEPRECATED iOSchedulerJobSendToMainloop ["(Since version 2.36)","Use @/g_main_context_invoke()/@."] #-}
iOSchedulerJobSendToMainloop ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOSchedulerJob
-> GLib.Callbacks.SourceFunc
-> m Bool
iOSchedulerJobSendToMainloop :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
IOSchedulerJob -> SourceFunc -> m Bool
iOSchedulerJobSendToMainloop IOSchedulerJob
job SourceFunc
func = SourceFunc -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (SourceFunc -> m Bool) -> SourceFunc -> m Bool
forall a b. (a -> b) -> a -> b
$ do
job' <- IOSchedulerJob -> IO (Ptr IOSchedulerJob)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOSchedulerJob
job
func' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc func))
let userData = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
func'
let notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
SP.safeFreeFunPtrPtr
result <- g_io_scheduler_job_send_to_mainloop job' func' userData notify
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr job
return result'
#if defined(ENABLE_OVERLOADING)
data IOSchedulerJobSendToMainloopMethodInfo
instance (signature ~ (GLib.Callbacks.SourceFunc -> m Bool), MonadIO m) => O.OverloadedMethod IOSchedulerJobSendToMainloopMethodInfo IOSchedulerJob signature where
overloadedMethod = iOSchedulerJobSendToMainloop
instance O.OverloadedMethodInfo IOSchedulerJobSendToMainloopMethodInfo IOSchedulerJob where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Structs.IOSchedulerJob.iOSchedulerJobSendToMainloop",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Structs-IOSchedulerJob.html#v:iOSchedulerJobSendToMainloop"
})
#endif
foreign import ccall "g_io_scheduler_job_send_to_mainloop_async" g_io_scheduler_job_send_to_mainloop_async ::
Ptr IOSchedulerJob ->
FunPtr GLib.Callbacks.C_SourceFunc ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO ()
{-# DEPRECATED iOSchedulerJobSendToMainloopAsync ["(Since version 2.36)","Use @/g_main_context_invoke()/@."] #-}
iOSchedulerJobSendToMainloopAsync ::
(B.CallStack.HasCallStack, MonadIO m) =>
IOSchedulerJob
-> GLib.Callbacks.SourceFunc
-> m ()
iOSchedulerJobSendToMainloopAsync :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
IOSchedulerJob -> SourceFunc -> m ()
iOSchedulerJobSendToMainloopAsync IOSchedulerJob
job SourceFunc
func = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
job' <- IOSchedulerJob -> IO (Ptr IOSchedulerJob)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr IOSchedulerJob
job
func' <- GLib.Callbacks.mk_SourceFunc (GLib.Callbacks.wrap_SourceFunc Nothing (GLib.Callbacks.drop_closures_SourceFunc func))
let userData = FunPtr C_SourceFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_SourceFunc
func'
let notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
SP.safeFreeFunPtrPtr
g_io_scheduler_job_send_to_mainloop_async job' func' userData notify
touchManagedPtr job
return ()
#if defined(ENABLE_OVERLOADING)
data IOSchedulerJobSendToMainloopAsyncMethodInfo
instance (signature ~ (GLib.Callbacks.SourceFunc -> m ()), MonadIO m) => O.OverloadedMethod IOSchedulerJobSendToMainloopAsyncMethodInfo IOSchedulerJob signature where
overloadedMethod = iOSchedulerJobSendToMainloopAsync
instance O.OverloadedMethodInfo IOSchedulerJobSendToMainloopAsyncMethodInfo IOSchedulerJob where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Structs.IOSchedulerJob.iOSchedulerJobSendToMainloopAsync",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Structs-IOSchedulerJob.html#v:iOSchedulerJobSendToMainloopAsync"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveIOSchedulerJobMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveIOSchedulerJobMethod "sendToMainloop" o = IOSchedulerJobSendToMainloopMethodInfo
ResolveIOSchedulerJobMethod "sendToMainloopAsync" o = IOSchedulerJobSendToMainloopAsyncMethodInfo
ResolveIOSchedulerJobMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveIOSchedulerJobMethod t IOSchedulerJob, O.OverloadedMethod info IOSchedulerJob p) => OL.IsLabel t (IOSchedulerJob -> 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 ~ ResolveIOSchedulerJobMethod t IOSchedulerJob, O.OverloadedMethod info IOSchedulerJob p, R.HasField t IOSchedulerJob p) => R.HasField t IOSchedulerJob p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveIOSchedulerJobMethod t IOSchedulerJob, O.OverloadedMethodInfo info IOSchedulerJob) => OL.IsLabel t (O.MethodProxy info IOSchedulerJob) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif