Module: @accessors-hosts/common/sync-atom

Timed events are delayed callbacks, scheduled using setTimeout or setInterval. This module offers variants of setTimeout, clearTimeout, setInterval, clearInterval, and reset that enforce a synchronous semantics for timed events. Synchronization between timed events entails the following two properties: (1) A timed event that is released from within another timed event that occurred at T=tau, will occur precisely at T=tau+timeout. (2) Any two events t1, t2, with intervals i1, i2, that are released from within the same function will occur precisely at T=tau+i2 and T=tau+i2, respectively. The value of tau will approximate the wallclock time of the first-released event. At common multiples of i1 and i2, t1 and t2 will execute simultenously i.e., in order of their release, and with no logical time elapsing until both have executed. In the rare case the same function happens to execute multiple times consequtively, without some timed event occurring in between, all releases in that series will be scheduled with respect to the same tau. Note that this situation can only arise trough rapidly succeeding asynchronous callbacks. When precise timing is desired, this scenario must be avoided.

WARNING: this implementation will only work correctly if the JavaScript execution environment provides a working implementation of Function.caller. Also see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller Function.caller is supported by: Chrome, Firefox Gecko 1.0, IE 8, Opera, Safari, which includes the mobile version of these respective browsers. Function.caller will not work in strict mode.

Version:
  • $Id$
Author:
  • Marten Lohstroh
Source:
Version:
  • $Id$
Author:
  • Marten Lohstroh
Source:

Methods

(inner) CalendarQ()

Construct a new calendar queue.

Source:

(inner) CalendarQ()

Construct a new calendar queue.

Source:

(inner) Callback(fun, offset, period)

Construct a new Callback object.

Parameters:
Name Type Description
fun
offset
period
Source:

(inner) Callback(fun, offset, period)

Construct a new Callback object.

Parameters:
Name Type Description
fun
offset
period
Source:

(inner) clearIntervalSync(cbId)

Unschedule a periodic callback.

Parameters:
Name Type Description
cbId

Handle returned by setInterval().

Source:

(inner) clearIntervalSync(cbId)

Unschedule a periodic callback.

Parameters:
Name Type Description
cbId

Handle returned by setInterval().

Source:

(inner) clearTimeoutSync(cbId)

Unschedule a delayed callback.

Parameters:
Name Type Description
cbId

Handle returned by setTimeout().

Source:

(inner) clearTimeoutSync(cbId)

Unschedule a delayed callback.

Parameters:
Name Type Description
cbId

Handle returned by setTimeout().

Source:

(inner) Event(id, time)

Construct a new Event object.

Parameters:
Name Type Description
id
time
Source:

(inner) Event(id, time)

Construct a new Event object.

Parameters:
Name Type Description
id
time
Source:

(inner) reset()

Clear all (period) timed events.

Source:

(inner) reset()

Clear all (period) timed events.

Source:

(inner) schedule(callback, timeout, caller, repeat)

Schedule a new timed event. This entails adding to the callbacks dictonary, as well as adding it to the calendar queue, and if needed, (re)setting a timer to wake up in time to process enabled events.

Parameters:
Name Type Description
callback

The callback to be scheduled.

timeout

The interval with respect to the current time.

caller

The function from which this event was released.

repeat

Whether this timed event is periodic or not.

Source:
Returns:

the id of the event.

(inner) schedule(callback, timeout, caller, repeat)

Schedule a new timed event. This entails adding to the callbacks dictonary, as well as adding it to the calendar queue, and if needed, (re)setting a timer to wake up in time to process enabled events.

Parameters:
Name Type Description
callback

The callback to be scheduled.

timeout

The interval with respect to the current time.

caller

The function from which this event was released.

repeat

Whether this timed event is periodic or not.

Source:
Returns:

the id of the event.

(inner) setIntervalSync(callback, timeout)

Schedule a periodic timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of the setInterval call.

(inner) setIntervalSync(callback, timeout)

Schedule a periodic timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of the setInterval call.

(inner) setTimeoutSync(callback, timeout)

Schedule a timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of setTimeout call

(inner) setTimeoutSync(callback, timeout)

Schedule a timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of setTimeout call

(inner) tick()

Wake up and process enabled events.

Source:

(inner) tick()

Wake up and process enabled events.

Source:

Timed events are delayed callbacks, scheduled using setTimeout or setInterval. This module offers variants of setTimeout, clearTimeout, setInterval, clearInterval, and reset that enforce a synchronous semantics for timed events. Synchronization between timed events entails the following two properties: (1) A timed event that is released from within another timed event that occurred at T=tau, will occur precisely at T=tau+timeout. (2) Any two events t1, t2, with intervals i1, i2, that are released from within the same function will occur precisely at T=tau+i2 and T=tau+i2, respectively. The value of tau will approximate the wallclock time of the first-released event. At common multiples of i1 and i2, t1 and t2 will execute simultenously i.e., in order of their release, and with no logical time elapsing until both have executed. In the rare case the same function happens to execute multiple times consequtively, without some timed event occurring in between, all releases in that series will be scheduled with respect to the same tau. Note that this situation can only arise trough rapidly succeeding asynchronous callbacks. When precise timing is desired, this scenario must be avoided.

WARNING: this implementation will only work correctly if the JavaScript execution environment provides a working implementation of Function.caller. Also see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller Function.caller is supported by: Chrome, Firefox Gecko 1.0, IE 8, Opera, Safari, which includes the mobile version of these respective browsers. Function.caller will not work in strict mode.

Version:
  • $Id$
Author:
  • Marten Lohstroh
Source:
Version:
  • $Id$
Author:
  • Marten Lohstroh
Source:

Methods

(inner) CalendarQ()

Construct a new calendar queue.

Source:

(inner) CalendarQ()

Construct a new calendar queue.

Source:

(inner) Callback(fun, offset, period)

Construct a new Callback object.

Parameters:
Name Type Description
fun
offset
period
Source:

(inner) Callback(fun, offset, period)

Construct a new Callback object.

Parameters:
Name Type Description
fun
offset
period
Source:

(inner) clearIntervalSync(cbId)

Unschedule a periodic callback.

Parameters:
Name Type Description
cbId

Handle returned by setInterval().

Source:

(inner) clearIntervalSync(cbId)

Unschedule a periodic callback.

Parameters:
Name Type Description
cbId

Handle returned by setInterval().

Source:

(inner) clearTimeoutSync(cbId)

Unschedule a delayed callback.

Parameters:
Name Type Description
cbId

Handle returned by setTimeout().

Source:

(inner) clearTimeoutSync(cbId)

Unschedule a delayed callback.

Parameters:
Name Type Description
cbId

Handle returned by setTimeout().

Source:

(inner) Event(id, time)

Construct a new Event object.

Parameters:
Name Type Description
id
time
Source:

(inner) Event(id, time)

Construct a new Event object.

Parameters:
Name Type Description
id
time
Source:

(inner) reset()

Clear all (period) timed events.

Source:

(inner) reset()

Clear all (period) timed events.

Source:

(inner) schedule(callback, timeout, caller, repeat)

Schedule a new timed event. This entails adding to the callbacks dictonary, as well as adding it to the calendar queue, and if needed, (re)setting a timer to wake up in time to process enabled events.

Parameters:
Name Type Description
callback

The callback to be scheduled.

timeout

The interval with respect to the current time.

caller

The function from which this event was released.

repeat

Whether this timed event is periodic or not.

Source:
Returns:

the id of the event.

(inner) schedule(callback, timeout, caller, repeat)

Schedule a new timed event. This entails adding to the callbacks dictonary, as well as adding it to the calendar queue, and if needed, (re)setting a timer to wake up in time to process enabled events.

Parameters:
Name Type Description
callback

The callback to be scheduled.

timeout

The interval with respect to the current time.

caller

The function from which this event was released.

repeat

Whether this timed event is periodic or not.

Source:
Returns:

the id of the event.

(inner) setIntervalSync(callback, timeout)

Schedule a periodic timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of the setInterval call.

(inner) setIntervalSync(callback, timeout)

Schedule a periodic timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of the setInterval call.

(inner) setTimeoutSync(callback, timeout)

Schedule a timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of setTimeout call

(inner) setTimeoutSync(callback, timeout)

Schedule a timed event.

Parameters:
Name Type Description
callback

The function to be executed.

timeout

The interval with respect to the (re)current time.

Source:
Returns:

the unique id of setTimeout call

(inner) tick()

Wake up and process enabled events.

Source:

(inner) tick()

Wake up and process enabled events.

Source: