mthread  0.5.1
Public Member Functions | Protected Member Functions | Private Attributes
ThreadList Class Reference

An object 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. More...

#include <mthread.h>

Inheritance diagram for ThreadList:
Thread

List of all members.

Public Member Functions

 ThreadList (bool keep=false)
 Constructor.
 ~ThreadList ()
 Destructor.
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
 If true, the ThreadList will not destroy itself when it becomes empty.

Detailed Description

An object 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.

Note:
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)

Constructor.

Parameters:
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

Adds a Thread to the ThreadList.

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

The main loop.

See also:
Thread::loop().

Reimplemented from Thread.


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