Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ThreadId
- type SysCall effs systemEvent a = Either (MessageCall systemEvent) (ThreadCall effs systemEvent a)
- data MessageCall systemEvent
- = WaitForMessage
- | Broadcast systemEvent
- | Message ThreadId systemEvent
- data ThreadCall effs systemEvent a
- data WithPriority t = WithPriority {}
- data Priority
- data Tag
- type EmSystemCall effs systemEvent a = WithPriority (SysCall effs systemEvent a)
- type AgentSystemCall systemEvent = WithPriority (MessageCall systemEvent)
- type SuspendedThread effs systemEvent a = WithPriority (EmThread effs systemEvent a)
- data EmThread effs systemEvent a = EmThread {
- _continuation :: Maybe systemEvent -> Eff effs (Status effs (EmSystemCall effs systemEvent a) (Maybe systemEvent) ())
- _threadId :: ThreadId
- _tag :: Tag
- data SchedulerState effs systemEvent a = SchedulerState {
- _normalPrio :: Seq (EmThread effs systemEvent a)
- _sleeping :: Seq (EmThread effs systemEvent a)
- _frozen :: Seq (EmThread effs systemEvent a)
- _lastThreadId :: ThreadId
- _mailboxes :: HashMap ThreadId (Seq systemEvent)
- _activeThreads :: Map Tag (HashSet ThreadId)
- runThreads :: forall a effs systemEvent. (Eq systemEvent, Member (LogMsg SchedulerLog) effs) => Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () -> Eff effs (Maybe a)
- fork :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => Tag -> Priority -> Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () -> Eff effs2 (Maybe systemEvent)
- sleep :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => Priority -> Eff effs2 (Maybe systemEvent)
- exit :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => a -> Eff effs2 (Maybe systemEvent)
- mkThread :: Tag -> Priority -> Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () -> ThreadId -> SuspendedThread effs systemEvent a
- mkSysCall :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => Priority -> SysCall effs systemEvent a -> Eff effs2 (Maybe systemEvent)
- mkAgentSysCall :: forall effs systemEvent. Member (Yield (AgentSystemCall systemEvent) (Maybe systemEvent)) effs => Priority -> MessageCall systemEvent -> Eff effs (Maybe systemEvent)
- data SchedulerLog = SchedulerLog {}
- data ThreadEvent
Documentation
Unique identifier of a thread.
Instances
Eq ThreadId Source # | |
Ord ThreadId Source # | |
Defined in Plutus.Trace.Scheduler | |
Show ThreadId Source # | |
Generic ThreadId Source # | |
FromJSON ThreadId Source # | |
Defined in Plutus.Trace.Scheduler parseJSON :: Value -> Parser ThreadId parseJSONList :: Value -> Parser [ThreadId] | |
ToJSON ThreadId Source # | |
Defined in Plutus.Trace.Scheduler toEncoding :: ThreadId -> Encoding toJSONList :: [ThreadId] -> Value toEncodingList :: [ThreadId] -> Encoding | |
Hashable ThreadId Source # | |
Defined in Plutus.Trace.Scheduler | |
Pretty ThreadId Source # | |
Defined in Plutus.Trace.Scheduler prettyList :: [ThreadId] -> Doc ann | |
type Rep ThreadId Source # | |
Defined in Plutus.Trace.Scheduler |
type SysCall effs systemEvent a = Either (MessageCall systemEvent) (ThreadCall effs systemEvent a) Source #
data MessageCall systemEvent Source #
Sending messages to other threads and waiting for new messages to arrive.
WaitForMessage | Suspend ourselves (the caller) until we receive a message |
Broadcast systemEvent | Send a message to all threads |
Message ThreadId systemEvent | Send a message to a specific thread |
data ThreadCall effs systemEvent a Source #
The system calls we can make to the scheduler, affecting the the threads that are currently running.
data WithPriority t Source #
A thread with a Priority
.
Instances
Functor WithPriority Source # | |
Defined in Plutus.Trace.Scheduler fmap :: (a -> b) -> WithPriority a -> WithPriority b Source # (<$) :: a -> WithPriority b -> WithPriority a Source # |
Priority of a thread.
Normal | Thread is ready to run |
Sleeping | Thread is sleeping, to be resumed only after an external event happens |
Frozen | Thread is frozen, it will only be resumed after it is manually unfrozen via the |
Instances
Eq Priority Source # | |
Show Priority Source # | |
Generic Priority Source # | |
FromJSON Priority Source # | |
Defined in Plutus.Trace.Scheduler parseJSON :: Value -> Parser Priority parseJSONList :: Value -> Parser [Priority] | |
ToJSON Priority Source # | |
Defined in Plutus.Trace.Scheduler toEncoding :: Priority -> Encoding toJSONList :: [Priority] -> Value toEncodingList :: [Priority] -> Encoding | |
Pretty Priority Source # | |
Defined in Plutus.Trace.Scheduler prettyList :: [Priority] -> Doc ann | |
type Rep Priority Source # | |
Defined in Plutus.Trace.Scheduler type Rep Priority = D1 ('MetaData "Priority" "Plutus.Trace.Scheduler" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) (C1 ('MetaCons "Normal" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Sleeping" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Frozen" 'PrefixI 'False) (U1 :: Type -> Type))) |
A human-readable piece of data, used to identify threads and contract instances. See note [Thread Tag]
Instances
Eq Tag Source # | |
Ord Tag Source # | |
Show Tag Source # | |
IsString Tag Source # | |
Defined in Plutus.Trace.Tag fromString :: String -> Tag Source # | |
Generic Tag Source # | |
FromJSON Tag Source # | |
Defined in Plutus.Trace.Tag parseJSON :: Value -> Parser Tag parseJSONList :: Value -> Parser [Tag] | |
ToJSON Tag Source # | |
Defined in Plutus.Trace.Tag | |
Pretty Tag Source # | |
Defined in Plutus.Trace.Tag prettyList :: [Tag] -> Doc ann | |
type Rep Tag Source # | |
Defined in Plutus.Trace.Tag |
type EmSystemCall effs systemEvent a = WithPriority (SysCall effs systemEvent a) Source #
type AgentSystemCall systemEvent = WithPriority (MessageCall systemEvent) Source #
type SuspendedThread effs systemEvent a = WithPriority (EmThread effs systemEvent a) Source #
data EmThread effs systemEvent a Source #
Thread that can be run by the scheduler
EmThread | |
|
data SchedulerState effs systemEvent a Source #
Scheduler state
SchedulerState | |
|
Thread API
runThreads :: forall a effs systemEvent. (Eq systemEvent, Member (LogMsg SchedulerLog) effs) => Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () -> Eff effs (Maybe a) Source #
Handle the 'Yield (EmSystemCall effs systemEvent) (Maybe systemEvent)'
effect using the scheduler, see note [Scheduler]. runThreads
only
returns when all threads are finished, returning Nothing
, or when
exit
is called, in which case the value passed to exit
is returned.
:: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 | |
=> Tag | Tag of the new thread. See note [Thread Tag] |
-> Priority | Priority of the new thread. |
-> Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () | |
-> Eff effs2 (Maybe systemEvent) |
Start a new thread
sleep :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => Priority -> Eff effs2 (Maybe systemEvent) Source #
Suspend the current thread
exit :: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 => a -> Eff effs2 (Maybe systemEvent) Source #
Stop the scheduler and let it return with the given value.
Etc.
mkThread :: Tag -> Priority -> Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent) ': effs)) () -> ThreadId -> SuspendedThread effs systemEvent a Source #
Make a thread with the given priority from an action. This is a
convenience for defining SimulatorInterpreter
values.
:: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 | |
=> Priority | The |
-> SysCall effs systemEvent a | The system call |
-> Eff effs2 (Maybe systemEvent) |
Make a system call
:: forall effs systemEvent. Member (Yield (AgentSystemCall systemEvent) (Maybe systemEvent)) effs | |
=> Priority | The |
-> MessageCall systemEvent | The system call |
-> Eff effs (Maybe systemEvent) |
Make a MessageCall
system call for some agent
data SchedulerLog Source #
Instances
data ThreadEvent Source #