# schedule -- schedule a task for execution

## Synopsis

• Usage:
schedule(f,x)
schedule f
schedule t
• Inputs:
• f, ,
• x, ,
• Outputs:
• a new task computing the value of the f(x), or, if x is not provided, then of f(). Alternatively, the task t, created previously with createTask, is scheduled for execution.

## Description

The computation proceeds in the background, in a thread. The status of the task can be observed by printing t. When the computation is finished, as can be detected with isReady(Task), the final value can be retrieved with taskResult(Task).

If notify is set to true, then useful messages are printed when the task changes state.

 i1 : f = x -> 2^x o1 = f o1 : FunctionClosure i2 : t = createTask(f,3) o2 = <> o2 : Task i3 : schedule t o3 = <> o3 : Task i4 : while not isReady t do sleep 1 i5 : taskResult t o5 = 8 i6 : u = schedule(f,4) o6 = <> o6 : Task i7 : while not isReady u do sleep 1 i8 : taskResult u o8 = 16

## Ways to use schedule :

• "schedule(Function)"
• "schedule(Function,Thing)"