UI::Util::ProcessThread Class Referenceabstract

Simple encapsulation for any process based threading system. More...

`#include <Thread.hpp>`

Inheritance diagram for UI::Util::ProcessThread:
Collaboration diagram for UI::Util::ProcessThread:

## Public Types

enum | ReservedStatus { NotRunYet_ = 255 , Running_ = 254 , WaitpidErr_ = 253 , KilledByUncatchedSignal_ = 252 }
| Reserved exit status'. Do not use these as return codes in your run()-functions. More...

## Public Member Functions

virtual void | start ()=0
| Start fork "thread".
bool | isRunning ()
pid_t | getPID () const
| Get PID of running "thread".
int | wait ()
| Wait for this "thread", and return the process' exit status.
int | getStatus () const
| Get status of last run.

## Protected Member Functions

virtual int | run ()=0

## Protected Attributes

pid_t | pid_
int | status_

## Detailed Description

Simple encapsulation for any process based threading system.

You need to overload "start" and "run".

Examples
  Threads.cpp.

## Member Enumeration Documentation

## ReservedStatus

enum UI::Util::ProcessThread::ReservedStatus

Reserved exit status'. Do not use these as return codes in your run()-functions.

Program exit status' are always between (including) 0..255; to be able to use the exit status directly in programs (e.g. for std::exit()), we reserve some values here (rather than using out-of-range values).

## Member Function Documentation

## isRunning()

bool UI::Util::ProcessThread::isRunning | ( |  | ) |

Check if "thread" is running.

References isRunning(), and status_.

Referenced by isRunning().

## run()

virtual int UI::Util::ProcessThread::run | ( |  | ) |

protected pure virtual

Virtual function of thread's task.

References wait().

Referenced by UI::Util::ForkThread::start().

## start()

virtual void UI::Util::ProcessThread::start | ( |  | ) |

pure virtual

Start fork "thread".

Implemented in UI::Util::ForkThread.

Examples
  Threads.cpp.

## wait()

int UI::Util::ProcessThread::wait | ( |  | ) |

Wait for this "thread", and return the process' exit status.

You must use this method to avoid zombies, or ignore all SIGCHLDs in the parent.

Examples
  Threads.cpp.

References status_, and wait().

Referenced by run(), and wait().

## Field Documentation

## pid_

pid_t UI::Util::ProcessThread::pid_

protected

Process id of thread: Must be set properly by overloaded start method.

Referenced by getPID(), and UI::Util::ForkThread::start().

## status_

int UI::Util::ProcessThread::status_

protected

Status of thread: Must be set properly by overloaded start method.

Referenced by getStatus(), isRunning(), UI::Util::ForkThread::start(), and wait().

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

- Thread.hpp
- Thread.cpp