Collapse:
Filter:
Classes (extension) | Function

Collapse : Object
ExtensionExtension

A class for collapsing multiple function calls into a single one.
Source: Collapse.sc

Description

The Collapse class is useful for deferring actions to a certain clock or scheduling them while reducing system load to a minimum. The Collapse takes a function to be deferred, a delta time span and a clock to defer to. An action is deferred by calling the defer method with arbitrary arguments. The function's value method is called with these arguments after the schedule delay. When defer is called before the function was executed, the function is deferred again by the schedule delay and the pending call is cancelled. The new arguments overwrite the previous (pending) arguments.

NOTE: This class was originally written by Hanns Holger Rutz (contact@sciss.de)

Class Methods

Collapse.new(func, delta: 0.0, clock)

Creates a new Collapse.

Arguments:

func

the function to execute when deferring; nil is allowed

delta

The amount of time to defer in seconds, defaults to 0.0. The first execution of the collapse will occur after delta, and subsequent executions are guaranteed to have delta seconds in between.

clock

The clock to execute the function within, defaults to AppClock

Inherited class methods

Instance Methods

.instantaneous( ... args)

Similiarly to defer, this sets the function args and schedules the collapse if it hadn't been started. Unlike defer, the scheduling delay is not reset.

Arguments:

... args

zero or more arguments which are passed to the function upon execution

.cancel

Cancel future executions of the function.

.value( ... args)

Schedule execute the function with the arguments args.

Arguments:

... args

zero or more arguments which are passed to the function upon execution

.defer( ... args)

(Re)schedules the function for execution with the given list of arguments.

Arguments:

... args

Zero or more arguments which are passed to the function upon execution.

.reschedule

Resets the scheduling delay to the original delta. If the collapse was not yet scheduled, this method will do it. The cancel status is cleared.

.listDefer(args)

(Re)schedules the function for execution with the arguments provided as an array.

Arguments:

args

an array of zero or more arguments which are passed to the function upon execution.

.listInstantaneous(args)

Similiarly to defer, this sets the function args and schedules the collapse if it hadn't been started. Unlike defer, the scheduling delay is not reset.

Arguments:

args

an array of zero or more arguments which are passed to the function upon

Inherited instance methods

Undocumented instance methods

.args

.cancelled

.clock

.clock =

.delta

.func

.prInit(argFunc, argDelta, argClock)

.prSetArgs(argArgs)

.started

Examples