SkipJack: table of contents
Classes | Scheduling | Libraries > JITLib > GUI

SkipJack : Object

A utility for background tasks that survive cmd-period
Subclasses: Watcher


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, dt: 0.2, stopTest: false, name: "anon", clock, autostart: true)



A Function to repeat in the background.


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


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


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


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.


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


Stop a skipjack by name.


Stop all skipjacks.


The default clock (AppClock)


SkipJack.verbose = value

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


The global set of all skipjacks.

Inherited class methods

Instance Methods


.dt = value

Get or set the time interval.


The internal Routine that wraps updateFunc.


The name of this skipjack.


.stopTest = value

The current stopTest. (see argument in *new )


Start this skipjack.


Same as start


Stop this skipjack.


.clock =

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


The updateFunc set by the argument to *new

Inherited instance methods


Simple example:

w = SkipJack({ "watch...".postln; }, 0.5, name: "test");
SkipJack.verbose = true;    // post stop/wakeup logs


//     now try to stop with cmd-. : SkipJack always restarts itself.


Using stopTest:

a = 5;
w = SkipJack({ "watch...".postln; }, 0.5, { a == 10 }, "test");
a = 10;    // fulfill stopTest

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

d = (a: 12, b: 24); = Window("dict", Rect(0,0,200,60)).front;
d.views = [\a, \b].collect { |name, i|
    StaticText(, Rect(i * 100,0,96,20))
w = SkipJack({
        [\a, \b].do { |name, i|
            d.views[i].string_(name ++ ":" + d[name])
    { },

d.a = 123;      // updates should be displayed
d.b = \otto;;    // when window closes, SkipJack stops.

If you need to get rid of an unreachable skipjack:

SkipJack({ "unreachable, unkillable...".postln }, name: "jack");

SkipJack.stopAll        // do this to stop all;

SkipJack.stop("jack");  // reach it by name and stop