Learn R Programming

simmer.bricks (version 0.2.2)

wait_n: Wait a Number of Signals

Description

These bricks encapsulate n stops: wait for a sequence of n signals. wait_until also traps and untraps the required signals.

Usage

wait_n(.trj, n = 1)

wait_until(.trj, signals, n = 1)

Value

wait_n returns n times wait. wait_until also adds trap and untrap at the beginning and end, respectively, of the chain of waits (see examples below).

Arguments

.trj

the trajectory object.

n

number of wait activities to chain.

signals

signal or list of signals, accepts either a string, a list of strings or a callable object (a function) which must return a string or a list of strings.

Examples

Run this code
## These are equivalent:
trajectory() %>%
  wait_n(3)

trajectory() %>%
  wait() %>%
  wait() %>%
  wait()

## These are equivalent:
trajectory() %>%
  wait_until("green")

trajectory() %>%
  trap("green") %>%
  wait() %>%
  untrap("green")

## These are equivalent:
trajectory() %>%
  wait_until(c("one", "another"), 2)

trajectory() %>%
  trap(c("one", "another")) %>%
  wait() %>%
  wait() %>%
  untrap(c("one", "another"))

Run the code above in your browser using DataLab