module Database.Perdure.StoreFile (
StoreFile(..),
SyncableStoreFile(..),
await0,
await1,
refSpan,
Word64,
BasicRef(..),
module Foreign.Ptr,
module Cgm.Data.Len,
module Validator
) where
import Prelude ()
import Cgm.Prelude
import Data.Word
import Foreign.Ptr
import Cgm.Data.Len
import Cgm.Data.Super
import Cgm.Control.Concurrent.Await
import Database.Perdure.Validator as Validator
import Cgm.System.Endian
import Cgm.Data.Structured
import Database.Perdure.Space
class SyncableStoreFile f => StoreFile f where
type StoreRef f :: * -> *
storeFileWrite :: Endian w => f -> Len Word64 Word64 -> Endianness -> [PrimArray Pinned w] -> IO (StoreRef f w)
storeFileRead :: (Validator v, ValidatedElem v ~ w, Endian w, LgMultiple w Word8) =>
f -> StoreRef f w -> Endianness -> v -> Async (Maybe (ArrayRange (PrimArray Pinned w))) ()
class SyncableStoreFile f where
storeFileSync :: f -> IO () -> IO ()
storeFileFullBarrier :: f -> IO ()
data BasicRef w = BasicRef {
refStart :: !(Len Word64 Word64),
refSize :: !(Len w Word32)}
refSpan :: forall w. LgMultiple Word64 w => BasicRef w -> Span
refSpan (BasicRef addr sz) = unsafeSortedPair (getLen addr) $ getLen $ (+ addr) $ coarsenLen (apply super sz :: Len w Word64)
deriveStructured ''BasicRef