{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE EmptyDataDecls #-}
module Database.PostgreSQL.LibPQ.Internal (
Connection (..),
withConn,
PGconn,
CNoticeBuffer,
NoticeBuffer,
) where
import Control.Concurrent.MVar (MVar)
import Foreign (ForeignPtr, Ptr, withForeignPtr)
data Connection = Conn {-# UNPACK #-} !(ForeignPtr PGconn)
{-# UNPACK #-} !(MVar NoticeBuffer)
instance Eq Connection where
(Conn ForeignPtr PGconn
c MVar NoticeBuffer
_) == :: Connection -> Connection -> Bool
== (Conn ForeignPtr PGconn
d MVar NoticeBuffer
_) = ForeignPtr PGconn
c ForeignPtr PGconn -> ForeignPtr PGconn -> Bool
forall a. Eq a => a -> a -> Bool
== ForeignPtr PGconn
d
(Conn ForeignPtr PGconn
c MVar NoticeBuffer
_) /= :: Connection -> Connection -> Bool
/= (Conn ForeignPtr PGconn
d MVar NoticeBuffer
_) = ForeignPtr PGconn
c ForeignPtr PGconn -> ForeignPtr PGconn -> Bool
forall a. Eq a => a -> a -> Bool
/= ForeignPtr PGconn
d
withConn :: Connection
-> (Ptr PGconn -> IO b)
-> IO b
withConn :: forall b. Connection -> (Ptr PGconn -> IO b) -> IO b
withConn (Conn !ForeignPtr PGconn
fp MVar NoticeBuffer
_) Ptr PGconn -> IO b
f = ForeignPtr PGconn -> (Ptr PGconn -> IO b) -> IO b
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PGconn
fp Ptr PGconn -> IO b
f
{-# INLINE withConn #-}
data PGconn
data CNoticeBuffer
type NoticeBuffer = Ptr CNoticeBuffer