SkipJack:
Filter:
Classes | Scheduling | JITLib > GUI

SkipJack : Object

A utility for background tasks that survive cmd-period
Source: SkipJack.sc

Description

SkipJack is a utility to run a function in the background repeatedly, that survive cmd-period.

A typical use is with a window displaying the state of some objects every now and then. (This is better in some cases than updating the GUI at every change. If the changes happen fast, you don't choke your CPU on gui updating.)

But SkipJack is useful whenever you need a periodic function to run in the background and not go away if the user hits cmd-period.

Class Methods

SkipJack.new(updateFunc, dt: 0.2, stopTest: false, name: "anon", clock, autostart: true)

Arguments:

updateFunc

A Function to repeat in the background.

dt

The time interval at which to repeat. It can also be a stream or a function that returns a number.

stopTest

A test whether to stop the task now. Usually a Function.

name

A name for this skipjack. Used for posting information and in the *stop classmethod.

clock

The clock that plays the task. Default is AppClock, so SkipJack can call GUI primitives. If you need more precise timing, you can supply your own clock, and use defer only where necessary.

autostart

When true (default) SkipJack starts automatically as it is created.

SkipJack.stop(name)

Stop a skipjack by name.

SkipJack.stopAll

Stop all skipjacks.

SkipJack.defaultClock

The default clock (AppClock)

SkipJack.verbose

SkipJack.verbose = value

When true, SkipJack posts messages when it starts, stops or restarts.

SkipJack.all

The global set of all skipjacks.

Inherited class methods

Instance Methods

.dt

.dt = value

Get or set the time interval.

.task

The internal Routine that wraps updateFunc.

.name

The name of this skipjack.

.stopTest

.stopTest = value

The current stopTest. (see argument in *new )

.start

Start this skipjack.

.play

Same as start

.stop

Stop this skipjack.

.clock

.clock =

Get or set the clock used. This will only be updated when the skipjack restarts.

.updateFunc

The updateFunc set by the argument to *new

Inherited instance methods

Examples

Simple example:

Using stopTest:

Typical use: SkipJack updates a window displaying the state of some objects every now and then.

If you need to get rid of an unreachable skipjack: