generated from tpl/purs
feat: workerdata
This commit is contained in:
parent
2a4892ce9c
commit
30eed65e65
@ -14,3 +14,6 @@ export const resourceLimitsImpl = () => worker.resourceLimits
|
|||||||
|
|
||||||
/** @type {(a: object) => () => void} */
|
/** @type {(a: object) => () => void} */
|
||||||
export const markUntransferableImpl = a => () => worker.markAsUntransferable(a)
|
export const markUntransferableImpl = a => () => worker.markAsUntransferable(a)
|
||||||
|
|
||||||
|
/** @type {() => unknown} */
|
||||||
|
export const workerDataImpl = () => worker.workerData
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
module Node.Worker (ResourceLimits, shareEnv, resourceLimits, isMainThread, threadId, markUntransferable) where
|
module Node.Worker (ResourceLimits, shareEnv, resourceLimits, isMainThread, threadId, markUntransferable, workerData) where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
|
import Control.Monad.Error.Class (liftEither)
|
||||||
|
import Data.Bifunctor (lmap)
|
||||||
import Data.Either (hush)
|
import Data.Either (hush)
|
||||||
import Data.Maybe (Maybe)
|
import Data.Maybe (Maybe)
|
||||||
import Effect (Effect)
|
import Effect (Effect)
|
||||||
|
import Effect.Exception (error)
|
||||||
import Foreign (Foreign)
|
import Foreign (Foreign)
|
||||||
import Node.Worker.Serializable (class Serializable, deserialize, serialize)
|
import Node.Worker.Serializable (class Serializable, deserialize, serialize)
|
||||||
|
|
||||||
@ -13,6 +16,10 @@ foreign import isMainThread :: Effect Boolean
|
|||||||
foreign import threadId :: Effect Int
|
foreign import threadId :: Effect Int
|
||||||
|
|
||||||
foreign import markUntransferableImpl :: Foreign -> Effect Unit
|
foreign import markUntransferableImpl :: Foreign -> Effect Unit
|
||||||
|
foreign import workerDataImpl :: Effect Foreign
|
||||||
|
|
||||||
|
workerData :: forall a. Serializable a => Effect a
|
||||||
|
workerData = bind workerDataImpl (liftEither <<< lmap error <<< deserialize)
|
||||||
|
|
||||||
markUntransferable :: forall a. Serializable a => a -> Effect Unit
|
markUntransferable :: forall a. Serializable a => a -> Effect Unit
|
||||||
markUntransferable = markUntransferableImpl <<< serialize
|
markUntransferable = markUntransferableImpl <<< serialize
|
||||||
|
Loading…
Reference in New Issue
Block a user