packages feed

HROOT-core-0.10.0.1: src/HROOT/Core/TMutex/Interface.hs

{-# LANGUAGE EmptyDataDecls, ExistentialQuantification,
  FlexibleContexts, FlexibleInstances, ForeignFunctionInterface,
  MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies,
  TypeSynonymInstances #-}
module HROOT.Core.TMutex.Interface where
import Data.Word
import Data.Int
import Foreign.C
import Foreign.Ptr
import FFICXX.Runtime.Cast
import HROOT.Core.TMutex.RawType
import HROOT.Core.TVirtualMutex.Interface

class (ITVirtualMutex a) => ITMutex a where

upcastTMutex :: forall a . (FPtr a, ITMutex a) => a -> TMutex
upcastTMutex h
  = let fh = get_fptr h
        fh2 :: Ptr RawTMutex = castPtr fh
      in cast_fptr_to_obj fh2

downcastTMutex :: forall a . (FPtr a, ITMutex a) => TMutex -> a
downcastTMutex h
  = let fh = get_fptr h
        fh2 = castPtr fh
      in cast_fptr_to_obj fh2