ComBase (CS2621 Emulator v0.1.0) View Source

ComBase emulates a distribtued application connected over a potentially asynchronous network.

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.

Get the current fuzzer list

Initialize the communication base.

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.

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.

Terminate communication base.

Set a timer for the given number of milliseconds, and send a message with the atom :timer when done.

Set a timer for the given number of milliseconds, and send a message with the atom message 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

Link to this function

append_fuzzers(ctx, fuzzer_list)

View Source

Specs

append_fuzzers(
  %ComBase{
    fuzz_chain: pid(),
    registration: term(),
    rev_registration: term(),
    times: term(),
    unfuzzables: term()
  },
  [{atom(), float() | pid()}]
) :: :ok

Add to the list of fuzzers used when messages are received. Note this function must be called before any messages are sent.

Specs

broadcast(
  %ComBase{
    fuzz_chain: term(),
    registration: pid(),
    rev_registration: pid(),
    times: term(),
    unfuzzables: term()
  },
  any()
) :: boolean()

Send message to all active processes.

Specs

get_fuzzers(%ComBase{
  fuzz_chain: pid(),
  registration: term(),
  rev_registration: term(),
  times: term(),
  unfuzzables: term()
}) :: [{atom(), float() | pid()}]

Get the current fuzzer list

Specs

init() :: %ComBase{
  fuzz_chain: pid(),
  registration: pid(),
  rev_registration: pid(),
  times: pid(),
  unfuzzables: pid()
}

Initialize the communication base.

Specs

list_proc(%ComBase{
  fuzz_chain: term(),
  registration: pid(),
  rev_registration: term(),
  times: term(),
  unfuzzables: term()
}) :: [atom()]

Get a list of all registed processes

Specs

mark_unfuzzable(%ComBase{
  fuzz_chain: term(),
  registration: term(),
  rev_registration: term(),
  times: term(),
  unfuzzables: pid()
}) :: :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

now(%ComBase{
  fuzz_chain: term(),
  registration: term(),
  rev_registration: term(),
  times: pid(),
  unfuzzables: term()
}) :: number()

Get current time.

Specs

send(
  %ComBase{
    fuzz_chain: term(),
    registration: pid(),
    rev_registration: pid(),
    times: term(),
    unfuzzables: term()
  },
  atom() | pid(),
  any()
) :: boolean()

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(
  %ComBase{
    fuzz_chain: term(),
    registration: term(),
    rev_registration: term(),
    times: pid(),
    unfuzzables: term()
  },
  number()
) :: :ok

Set current time.

Specs

spawn(
  %ComBase{
    fuzz_chain: term(),
    registration: pid(),
    rev_registration: pid(),
    times: pid(),
    unfuzzables: term()
  },
  atom(),
  (-> any())
) :: pid()

Spawn a process with supplied name and function.

Specs

terminate(%ComBase{
  fuzz_chain: pid(),
  registration: pid(),
  rev_registration: pid(),
  times: pid(),
  unfuzzables: term()
}) :: :ok

Terminate communication base.

Specs

timer(
  %ComBase{
    fuzz_chain: term(),
    registration: pid(),
    rev_registration: pid(),
    times: term(),
    unfuzzables: term()
  },
  non_neg_integer()
) :: reference()

Set a timer for the given number of milliseconds, and send a message with the atom :timer when done.

Specs

timer(
  %ComBase{
    fuzz_chain: term(),
    registration: pid(),
    rev_registration: pid(),
    times: term(),
    unfuzzables: term()
  },
  non_neg_integer(),
  atom()
) :: reference()

Set a timer for the given number of milliseconds, and send a message with the atom message when done.

Link to this function

translate_time(ctx, p, time)

View Source

Specs

translate_time(
  %ComBase{
    fuzz_chain: term(),
    registration: term(),
    rev_registration: term(),
    times: pid(),
    unfuzzables: term()
  },
  atom(),
  number()
) :: number()

Translate time (gotten from System.monotonic_time()) to time at process p. This should only be used for testing.

Specs

whoami(%ComBase{
  fuzz_chain: term(),
  registration: term(),
  rev_registration: pid(),
  times: term(),
  unfuzzables: term()
}) :: atom() | pid()

Get ID for the current process.