Module

Yoga.Om.WorkerBees.SharedMap

Package
purescript-yoga-om-workerbees
Repository
rowtype-yoga/purescript-yoga-om-workerbees

#SharedMap Source

newtype SharedMap a

A shared concurrent map backed by SharedArrayBuffer with striped locks. Keys are Strings, values must be JSON-serializable. The keyspace is split into N segments for N-way concurrency.

#new Source

new :: forall a. Int -> Int -> Effect (SharedMap a)

Create a new empty SharedMap. numSegments controls concurrency (e.g., 16 or 64). maxBytesPerSegment is the max JSON size per segment.

#lookup Source

lookup :: forall a. ReadForeign a => String -> SharedMap a -> Effect (Maybe a)

Look up a key. Returns Nothing if not found.

#insert Source

insert :: forall a. ReadForeign a => WriteForeign a => String -> a -> SharedMap a -> Effect Unit

Insert or overwrite a key-value pair.

#delete Source

delete :: forall a. ReadForeign a => WriteForeign a => String -> SharedMap a -> Effect Unit

Delete a key. No-op if key doesn't exist.

#modify Source

modify :: forall a. ReadForeign a => WriteForeign a => String -> (a -> a) -> SharedMap a -> Effect (Maybe a)

Atomically modify the value at a key. Returns the new value, or Nothing if not found.

#toSendable Source

toSendable :: forall a. SharedMap a -> SendWrapper (SharedMap a)

Wrap for worker transfer.

#fromSendable Source

fromSendable :: forall a. SendWrapper (SharedMap a) -> Effect (SharedMap a)

Unwrap on the worker side. Reconstructs Int32Array views from the shared buffer.