mthread 0.5
Public Member Functions | Protected Member Functions | Private Attributes

ThreadList Class Reference

A class for running several Thread objects simultaneously. More...

#include <mthread.h>

Inheritance diagram for ThreadList:

List of all members.

Public Member Functions

 ThreadList (bool keep=false)
 ~ThreadList ()
bool add_thread (Thread *t)
 Adds a Thread to the ThreadList.

Protected Member Functions

bool loop ()
 The main loop.

Private Attributes

Thread ** thread
 An array of pointers to the Thread objects in the list.
unsigned thread_count
 The number of Thread objects in the list.
unsigned thread_index
 The index number of the active Thread.
bool keep_flag
 Indicates whether or not to continue running the ThreadList after it has run out of Thread objects.

Detailed Description

A class for running several Thread objects simultaneously.

A ThreadList object is a Thread in and of itself. This allows the creation of tiered ThreadList objects by placing a lower-priority ThreadList inside of a higher-priority ThreadList.

DO NOT place a Thread in more than one ThreadList or more than once in a single ThreadList. DO NOT place a ThreadList inside of itself or one of its children. Also, DO NOT place the main_thread_list in another ThreadList. These WILL cause memory corruption (and are silly things to do in the first place).

Constructor & Destructor Documentation

ThreadList::ThreadList ( bool  keep = false)


keepIf true, the ThreadList will continue to run even after it's empty, otherwise it will automatically destroy itself once all of its Thread objects have finished.

Member Function Documentation

bool ThreadList::add_thread ( Thread t)

Adds a Thread to the ThreadList.

tA pointer to the Thread to be added.
true on success, false otherwise.
bool ThreadList::loop ( ) [protected, virtual]

The main loop.

See also:

Reimplemented from Thread.

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Defines