- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Executives::DeductiveController::Rtapi::MultiThreadedObject Class Reference

`#include <MultiThreadedObject.h>`

Inheritance diagram for Mers::Executives::DeductiveController::Rtapi::MultiThreadedObject:

[legend]
List of all members.

## Public Member Functions
| MultiThreadedObject ()
virtual | ~MultiThreadedObject ()
int | start ()
int | stop ()
## Protected Member Functions
virtual void * | run ()=0
## Protected Attributes
bool | m_ThreadIsRunning
pthread_t | m_Thread
| the thread of this object, if any.
pthread_attr_t | m_ThreadAttributes

## Detailed Description

A object that encapsulates the code necessary to spawn a new thread from the current thread. The new thread runs in this objects run() procedure.

Author:
  Paul H. Elliott

Definition at line 35 of file MultiThreadedObject.h.

## Constructor & Destructor Documentation

MultiThreadedObject::MultiThreadedObject | ( |  | ) |

creates a new MultiThreadedObject

Definition at line 26 of file MultiThreadedObject.cpp.

MultiThreadedObject::~MultiThreadedObject | ( |  | ) | `[virtual]`

destroys the multithreaded object, stoping the object if it was already running

Definition at line 32 of file MultiThreadedObject.cpp.

References m_ThreadIsRunning, and stop().

Here is the call graph for this function:

## Member Function Documentation

int MultiThreadedObject::start | ( |  | ) |

starts a new thread, if one isn't already running.

Returns:
  0 on success, a positive value on failure(errno value), or a negative value if a thread was already running

Definition at line 40 of file MultiThreadedObject.cpp.

References m_Thread, m_ThreadAttributes, and m_ThreadIsRunning.

Referenced by Mers::Executives::DeductiveController::Rtapi::ME::ME_dispatcher::ME_dispatcher(), and Mers::Executives::DeductiveController::Rtapi::MR::MR_dispatcher::MR_dispatcher().

int MultiThreadedObject::stop | ( |  | ) |

cancels this objects other thread, if already running, and merges it back into this thread before returning

Returns:
  0 on succes, a positive number (errno value) on failure, or a negative value if the thread was already stopped

Definition at line 74 of file MultiThreadedObject.cpp.

References m_ThreadIsRunning.

Referenced by ~MultiThreadedObject().

virtual void* Mers::Executives::DeductiveController::Rtapi::MultiThreadedObject::run | ( |  | ) | `[protected, pure virtual]`

this function is called by the newly spawned thread when the the start() function is called. This function should not return until the new thread is finished running

Returns:
  the return status of the run

Implemented in Mers::Executives::DeductiveController::Rtapi::ME::ME_dispatcher, and Mers::Executives::DeductiveController::Rtapi::MR::MR_dispatcher.

## Member Data Documentation

bool Mers::Executives::DeductiveController::Rtapi::MultiThreadedObject::m_ThreadIsRunning`[protected]`

This flag indicates if we have already created a thread or not, since the type of pthread_t is unknown.

Definition at line 95 of file MultiThreadedObject.h.

Referenced by Mers::Executives::DeductiveController::Rtapi::ME::ME_dispatcher::run(), start(), stop(), and ~MultiThreadedObject().

pthread_attr_t Mers::Executives::DeductiveController::Rtapi::MultiThreadedObject::m_ThreadAttributes`[protected]`

the attributes of the thread of this object. Note that these are set upon calling start().

Definition at line 102 of file MultiThreadedObject.h.

Referenced by start().

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/MultiThreadedObject.h
- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/MultiThreadedObject.cpp