plutus-contract-0.1.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 #

Hashable ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

ToJSON ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

FromJSON ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: ThreadId -> Doc ann Source #

prettyList :: [ThreadId] -> Doc ann Source #

type Rep ThreadId Source # 
Instance details

Defined in Plutus.Trace.Scheduler

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

type SysCall effs systemEvent = Either (MessageCall systemEvent) (ThreadCall effs systemEvent) 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 Source #

The system calls we can make to the scheduler, affecting the the threads that are currently running.

Constructors

Fork (ThreadId -> SuspendedThread effs systemEvent)

Start a new thread with a new thread ID.

Thaw ThreadId

Unfreeze a thread.

Exit

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 #

ToJSON Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

FromJSON Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Methods

pretty :: Priority -> Doc ann Source #

prettyList :: [Priority] -> Doc ann Source #

type Rep Priority Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep Priority = D1 ('MetaData "Priority" "Plutus.Trace.Scheduler" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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 #

ToJSON Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

FromJSON Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Pretty Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

Methods

pretty :: Tag -> Doc ann Source #

prettyList :: [Tag] -> Doc ann Source #

type Rep Tag Source # 
Instance details

Defined in Plutus.Trace.Tag

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

type EmSystemCall effs systemEvent = WithPriority (SysCall effs systemEvent) Source #

type AgentSystemCall systemEvent = WithPriority (MessageCall systemEvent) Source #

type SuspendedThread effs systemEvent = WithPriority (EmThread effs systemEvent) Source #

data EmThread effs systemEvent Source #

Thread that can be run by the scheduler

Constructors

EmThread 

Fields

data SchedulerState effs systemEvent Source #

Scheduler state

Constructors

SchedulerState 

Fields

Thread API

runThreads :: forall effs systemEvent. (Eq systemEvent, Member (LogMsg SchedulerLog) effs) => Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent) (Maybe systemEvent) ': effs)) () -> Eff effs () Source #

Handle the 'Yield (EmSystemCall effs systemEvent) (Maybe systemEvent)' effect using the scheduler, see note [Scheduler]. runThreads only returns when all threads are finished.

fork Source #

Arguments

:: forall effs systemEvent effs2. Member (Yield (EmSystemCall effs systemEvent) (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) (Maybe systemEvent) ': effs)) () 
-> Eff effs2 (Maybe systemEvent) 

Start a new thread

sleep :: forall effs systemEvent effs2. Member (Yield (EmSystemCall effs systemEvent) (Maybe systemEvent)) effs2 => Priority -> Eff effs2 (Maybe systemEvent) Source #

Suspend the current thread

exit :: forall effs systemEvent effs2. Member (Yield (EmSystemCall effs systemEvent) (Maybe systemEvent)) effs2 => Eff effs2 (Maybe systemEvent) Source #

Stop the scheduler.

Etc.

mkThread :: Tag -> Priority -> Eff (Reader ThreadId ': (Yield (EmSystemCall effs systemEvent) (Maybe systemEvent) ': effs)) () -> ThreadId -> SuspendedThread effs systemEvent 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. Member (Yield (EmSystemCall effs systemEvent) (Maybe systemEvent)) effs2 
=> Priority

The Priority of the caller

-> SysCall effs systemEvent

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 #

ToJSON SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

FromJSON SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep SchedulerLog Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep SchedulerLog = D1 ('MetaData "SchedulerLog" "Plutus.Trace.Scheduler" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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

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 #

ToJSON ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

FromJSON ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep ThreadEvent Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep ThreadEvent = D1 ('MetaData "ThreadEvent" "Plutus.Trace.Scheduler" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) ((C1 ('MetaCons "Stopped" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StopReason)) :+: 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))))

data StopReason Source #

Constructors

ThreadDone

The thread was done.

ThreadExit

The thread made the Exit system call.

Instances

Instances details
Eq StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Show StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Generic StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Associated Types

type Rep StopReason :: Type -> Type Source #

ToJSON StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

FromJSON StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

Pretty StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep StopReason Source # 
Instance details

Defined in Plutus.Trace.Scheduler

type Rep StopReason = D1 ('MetaData "StopReason" "Plutus.Trace.Scheduler" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "ThreadDone" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ThreadExit" 'PrefixI 'False) (U1 :: Type -> Type))