Task Server
1 Functions
task-server
task-server?
call-with-task-server
current-task-server
run-tasks
schedule-stop-task
schedule-task
schedule-delayed-task
schedule-recurring-task
schedule-event-task
schedule-recurring-event-task
2 Syntactic Forms
with-task-server
stop-task
task
recurring-task
delayed-task
event-task
recurring-event-task
6.12

Task Server

Jan Dvořák <[email protected]>

Enables event-driven programming using a central poller and a number of callback procedures.

 (require tasks) package: tasks

1 Functions

procedure

(task-server)  task-server?

Create new task server to pass along.

There is a default task server, so if you are not doing anything serious you can just use the functions below. It’s almost always better to use call-with-task-server or the with-task-server form instead if you really need one.

procedure

(task-server? v)  boolean?

  v : any/c
Predicate identifying a task server.

procedure

(call-with-task-server proc)  any

  proc : (-> any)
Call specified procedure proc with new current-task-server.

parameter

(current-task-server)  task-server?

(current-task-server task-server)  void?
  task-server : task-server?
Parameter identifying default task server for the procedures below.

procedure

(run-tasks [task-server])  void?

  task-server : task-server? = (current-task-server)
Enter the main loop, waiting for and executing defined tasks. To terminate the loop use schedule-stop-task.

procedure

(schedule-stop-task [task-server])  void?

  task-server : task-server? = (current-task-server)
Schedule task that will stop the task server at some close time or immediately if there are no other tasks scheduled.

procedure

(schedule-task proc [task-server])  void?

  proc : (-> any)
  task-server : task-server? = (current-task-server)
Schedule specified procedure proc to be executed soon.

procedure

(schedule-delayed-task proc    
  secs    
  [task-server])  void?
  proc : (-> any)
  secs : real?
  task-server : task-server? = (current-task-server)
Schedule specified procedure proc to be executed after at least specified number of seconds, defined by spec.

procedure

(schedule-recurring-task proc    
  secs    
  [task-server])  void?
  proc : (-> any)
  secs : real?
  task-server : task-server? = (current-task-server)
Schedule specified procedure proc to be executed periodically, with specified secs interval, starting soon after the call.

procedure

(schedule-event-task proc evt [task-server])  void?

  proc : procedure?
  evt : evt?
  task-server : task-server = (current-task-server)
Schedule specified procedure proc to be executed when specified event source evt becomes ready for synchronization. Synchronization result will form proc arguments.

procedure

(schedule-recurring-event-task proc    
  evt    
  [task-server])  void?
  proc : procedure?
  evt : evt?
  task-server : task-server = (current-task-server)
Schedule specified procedure proc to be execute every time specified event source evt becomes ready for synchronization. Synchronization result will form proc arguments.

2 Syntactic Forms

syntax

(with-task-server body ...)

Shortcut for (call-with-task-server (λ () body ...)).

syntax

(stop-task)

Shortcut for (schedule-stop-task).

syntax

(task body ...)

Shortcut for (schedule-task (λ () body ...)).

syntax

(recurring-task delay body ...)

Shortcut for (schedule-recurring-task (λ () body ...) delay).

syntax

(delayed-task delay body ...)

Shortcut for (schedule-delayed-task (λ () body ...) delay).

syntax

(event-task (evt . args) body ...)

Shortcut for (schedule-event-task (λ args body ...) evt).

syntax

(recurring-event-task (evt . args) body ...)

Shortcut for (schedule-recurring-event-task (λ args body ...) evt).