DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C++ Task Library

task.intro(C++)


task -- co-routines, multiple threads of control, C++ task library

Syntax

#include <task.h>

class object; class sched : public object; class timer : public sched; class task : public sched;

class qhead : public object; class qtail : public object;

class Interrupt_handler : public object;

class histogram; class randint; class urand : public randint; class erand : public randint;

Description

The C++ task library provides facilities for writing programs with multiple threads of control within one UNIX system process. Each thread of control is a task or co-routine. Each task is an instance of a user-defined class derived from class task, and the main program of the task is the constructor of its class. A task can be suspended and resumed without interfering with its internal state. Each task runs until it explicitly gives up the processor; there is no preemption.

Most classes in the task system are derived from the base class object. The base class sched is responsible for scheduling and for the functionality that is common to tasks and timers. Class sched is meant to be used strictly as a base class, that is, it is illegal to create objects of class sched. Class task must also be used only as a base class. The programmer must derive a class from class task, and provide a constructor to serve as the task's main program. The task system can be used for writing event-driven simulations. tasks execute in a simulated time frame. Objects of class timer provide a facility for implementing time-outs and other time-dependent phenomena. Classes task, timer, sched, and object and their public member functions are described on the task(C++) manual page.

Classes qhead and qtail enable a wide range of message-passing and data-buffering schemes to be implemented simply. These classes are described on the queue(C++) manual page.

Class Interrupt_handler provides an interface for writing classes that can wait for external events using UNIX system signals. These classes are described on the interrupt(C++) manual page.

Class histogram aids data gathering. Classes randint, urand, and erand provide random number generation. These four classes are described on the tasksim(C++) manual page.

See also

task(C++), queue(C++), interrupt(C++), tasksim(C++)

``A set of C++ classes for co-routine style programming,'' by Stroustrup, B. and Shopiro, J. E., in Chapter 2 of the C++ Library Manual.

``Extending the C++ task system for real-time control,'' by Shopiro, J. E., in Chapter 2 of the C++ Library Manual.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005