plutus-contract-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Trace.Scheduler

Synopsis

Documentation

data ThreadId Source #

Unique identifier of a thread.

Instances

Instances details
Eq ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Ord ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Show ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Generic ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Associated Types

type Rep ThreadId :: Type -> Type Source #

FromJSON ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

parseJSON :: Value -> Parser ThreadId

parseJSONList :: Value -> Parser [ThreadId]

ToJSON ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

toJSON :: ThreadId -> Value

toEncoding :: ThreadId -> Encoding

toJSONList :: [ThreadId] -> Value

toEncodingList :: [ThreadId] -> Encoding

Hashable ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: ThreadId -> Doc ann

prettyList :: [ThreadId] -> Doc ann

type Rep ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep ThreadId = D1 ('MetaData "ThreadId" "Plutus.Trace.Scheduler" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'True) (C1 ('MetaCons "ThreadId" 'PrefixI 'True) (S1 ('MetaSel ('Just "unThreadId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

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.

Constructors

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.

Constructors

Fork (ThreadId -> SuspendedThread effs systemEvent a)

Start a new thread with a new thread ID.

Thaw ThreadId

Unfreeze a thread.

Exit a

Terminate the scheduler.

data WithPriority t Source #

A thread with a Priority.

Constructors

WithPriority 

Fields

Instances

Instances details
Functor WithPriority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

fmap :: (a -> b) -> WithPriority a -> WithPriority b Source #

(<$) :: a -> WithPriority b -> WithPriority a Source #

data Priority Source #

Priority of a thread.

Constructors

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 Thaw sys call.

Instances

Instances details
Eq Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Show Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Generic Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Associated Types

type Rep Priority :: Type -> Type Source #

FromJSON Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

parseJSON :: Value -> Parser Priority

parseJSONList :: Value -> Parser [Priority]

ToJSON Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

toJSON :: Priority -> Value

toEncoding :: Priority -> Encoding

toJSONList :: [Priority] -> Value

toEncodingList :: [Priority] -> Encoding

Pretty Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: Priority -> Doc ann

prettyList :: [Priority] -> Doc ann

type Rep Priority Source # 
Instance details

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)))

data Tag Source #

A human-readable piece of data, used to identify threads and contract instances. See note [Thread Tag]

Instances

Instances details
Eq Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

(==) :: Tag -> Tag -> Bool Source #

(/=) :: Tag -> Tag -> Bool Source #

Ord Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

compare :: Tag -> Tag -> Ordering Source #

(<) :: Tag -> Tag -> Bool Source #

(<=) :: Tag -> Tag -> Bool Source #

(>) :: Tag -> Tag -> Bool Source #

(>=) :: Tag -> Tag -> Bool Source #

max :: Tag -> Tag -> Tag Source #

min :: Tag -> Tag -> Tag Source #

Show Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

IsString Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Generic Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Associated Types

type Rep Tag :: Type -> Type Source #

Methods

from :: Tag -> Rep Tag x Source #

to :: Rep Tag x -> Tag Source #

FromJSON Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

parseJSON :: Value -> Parser Tag

parseJSONList :: Value -> Parser [Tag]

ToJSON Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

toJSON :: Tag -> Value

toEncoding :: Tag -> Encoding

toJSONList :: [Tag] -> Value

toEncodingList :: [Tag] -> Encoding

Pretty Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

pretty :: Tag -> Doc ann

prettyList :: [Tag] -> Doc ann

type Rep Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

type Rep Tag = D1 ('MetaData "Tag" "Plutus.Trace.Tag" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'True) (C1 ('MetaCons "Tag" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

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

Constructors

EmThread 

Fields

data SchedulerState effs systemEvent a Source #

Scheduler state

Constructors

SchedulerState 

Fields

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.

fork Source #

Arguments

:: 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.

mkSysCall Source #

Arguments

:: forall effs systemEvent effs2 a. Member (Yield (EmSystemCall effs systemEvent a) (Maybe systemEvent)) effs2 
=> Priority

The Priority of the caller

-> SysCall effs systemEvent a

The system call

-> Eff effs2 (Maybe systemEvent) 

Make a system call

mkAgentSysCall Source #

Arguments

:: forall effs systemEvent. Member (Yield (AgentSystemCall systemEvent) (Maybe systemEvent)) effs 
=> Priority

The Priority of the caller

-> MessageCall systemEvent

The system call

-> Eff effs (Maybe systemEvent) 

Make a MessageCall system call for some agent

data SchedulerLog Source #

Instances

Instances details
Eq SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Show SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Generic SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Associated Types

type Rep SchedulerLog :: Type -> Type Source #

FromJSON SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

parseJSON :: Value -> Parser SchedulerLog

parseJSONList :: Value -> Parser [SchedulerLog]

ToJSON SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

toJSON :: SchedulerLog -> Value

toEncoding :: SchedulerLog -> Encoding

toJSONList :: [SchedulerLog] -> Value

toEncodingList :: [SchedulerLog] -> Encoding

Pretty SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: SchedulerLog -> Doc ann

prettyList :: [SchedulerLog] -> Doc ann

type Rep SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep SchedulerLog = D1 ('MetaData "SchedulerLog" "Plutus.Trace.Scheduler" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) (C1 ('MetaCons "SchedulerLog" 'PrefixI 'True) ((S1 ('MetaSel ('Just "slEvent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ThreadEvent) :*: S1 ('MetaSel ('Just "slThread") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ThreadId)) :*: (S1 ('MetaSel ('Just "slTag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tag) :*: S1 ('MetaSel ('Just "slPrio") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Priority))))

data ThreadEvent Source #

Instances

Instances details
Eq ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Ord ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Show ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Generic ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Associated Types

type Rep ThreadEvent :: Type -> Type Source #

FromJSON ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

parseJSON :: Value -> Parser ThreadEvent

parseJSONList :: Value -> Parser [ThreadEvent]

ToJSON ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

toJSON :: ThreadEvent -> Value

toEncoding :: ThreadEvent -> Encoding

toJSONList :: [ThreadEvent] -> Value

toEncodingList :: [ThreadEvent] -> Encoding

Pretty ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: ThreadEvent -> Doc ann

prettyList :: [ThreadEvent] -> Doc ann

type Rep ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep ThreadEvent = D1 ('MetaData "ThreadEvent" "Plutus.Trace.Scheduler" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) ((C1 ('MetaCons "Stopped" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Resumed" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Suspended" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Started" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Thawed" 'PrefixI 'False) (U1 :: Type -> Type))))