CS2621 Emulator v0.1.0 Emulation View Source
This module is a wrapper around ComBase that simplifies its use in student code. It does so by saving the context as a named Agent, and retrieving it when necessary.
Link to this section Summary
Functions
Add to the list of fuzzers used when messages are received. Note this function must be called before any messages are sent.
Send message to all active processes.
Convert emulation time units (e.g., from succesive calls to now
)
into microsecons. This is useful for human readable output.
Convert emulation time units (e.g., from succesive calls to now
)
into milliseconds. This is useful for human readable output.
Get the current fuzzer list
Setup the emulation
Get a list of all registed processes
Mark this process as one whose messages (i.e., those sent or received by the process) should not be fuzzed. This is meant as an aid to testing, and should not be used by code not within a test.
Convert milliseconds to emulation time units. This is useful when providing estimates.
Get current time.
Send a message to the process named proc. Message can be anything. ctx should be the context in which the process was created.
Set current time.
Spawn a process with supplied name and function.
Teardown emulation
Set a timer for ms
milliseconds, and send a message
to the calling process with the atom :timer
when done.
Set a timer for ms
milliseconds, and send a message to
the calling process with atom
when done.
Translate time
(gotten from System.monotonic_time()
) to time
at process p
. This should only be used for testing.
Get ID for the current process.
Link to this section Functions
Specs
Add to the list of fuzzers used when messages are received. Note this function must be called before any messages are sent.
Specs
Send message to all active processes.
Specs
Cancel a timer previously set using either timer/1
or
timer/2
. timer
is the reference returned by those
calls. Returns the number of milliseconds left on the
timer or false
if the timer had already expired.
Specs
Convert emulation time units (e.g., from succesive calls to now
)
into microsecons. This is useful for human readable output.
Specs
Convert emulation time units (e.g., from succesive calls to now
)
into milliseconds. This is useful for human readable output.
Specs
Get the current fuzzer list
Specs
init() :: {:ok, pid()}
Setup the emulation
Specs
list_proc() :: [atom()]
Get a list of all registed processes
Specs
mark_unfuzzable() :: :ok
Mark this process as one whose messages (i.e., those sent or received by the process) should not be fuzzed. This is meant as an aid to testing, and should not be used by code not within a test.
Specs
Convert milliseconds to emulation time units. This is useful when providing estimates.
Specs
now() :: number()
Get current time.
Specs
Send a message to the process named proc. Message can be anything. ctx should be the context in which the process was created.
Specs
set_time(number()) :: :ok
Set current time.
Specs
Spawn a process with supplied name and function.
Teardown emulation
Specs
timer(non_neg_integer()) :: reference()
Set a timer for ms
milliseconds, and send a message
to the calling process with the atom :timer
when done.
Specs
timer(non_neg_integer(), atom()) :: reference()
Set a timer for ms
milliseconds, and send a message to
the calling process with atom
when done.
Specs
Translate time
(gotten from System.monotonic_time()
) to time
at process p
. This should only be used for testing.
Specs
Get ID for the current process.