Skip to content

stdtime

Anssi Halmeaho edited this page Apr 28, 2020 · 1 revision

stdtime

Timer related services.

timer (opaque type)

Opaque type timer represents timer data structure.

ticker (opaque type)

Opaque type ticker represents ticker data structure. Ticker is used for periodical timing.

Procedures

sleep

Calling fiber sleeps N seconds, where N is given as argument (argument type is int).

type: procedure

Format:

call(stdtime.sleep <int>) -> true

Return value: true

nanosleep

Calling fiber sleeps N nanoseconds, where N is given as argument (argument type is int).

type: procedure

Format:

call(stdtime.nanosleep <int>) -> true

Return value: true

newtimer

Creates timer, caller gives time limit, channel and value as arguments. When timer expires given value is written to given channel.

type: procedure

Arguments:

  1. time limit (int)
  2. channel
  3. value which is sent to channel when timer expires

Format:

call(stdtime.newtimer <int> <channel> <value>) -> <timer>

Return value: timer value

callafter

Creates timer, caller gives time limit and procedure which is called when timer expires.

type: procedure

Format:

call(stdtime.callafter <int> <handler-proc>) -> <timer>

Return value: timer value

stoptimer

Stops timer that is given as argument.

type: procedure

Format:

call(stdtime.stoptimer <timer>) -> <bool>

Return value: true if timer was found, false otherwise

newticker

Creates ticker, caller gives tick-period, channel and value as arguments. When tick happens given value is written to given channel.

type: procedure

Arguments:

  1. ticker period (int)
  2. channel
  3. value which is sent to channel when tick happens

Format:

call(stdtime.newticker <int> <channel> <value>) -> <ticker>

Return value: ticker value

stopticker

Stops ticker that is given as argument.

type: procedure

Format:

call(stdtime.stopticker <ticker>) -> true

Return value: true

Clone this wiki locally