ui-utilcpp 1.10.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
UI::Util::ProcessThread Class Referenceabstract

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

#include <Thread.hpp>

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

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". More...
 
bool isRunning ()
 
pid_t getPID () const
 Get PID of running "thread".
 
int wait ()
 Wait for this "thread", and return the process' exit status. More...
 
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

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.

◆ run()

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

Virtual function of thread's task.

◆ 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.

Field Documentation

◆ pid_

pid_t UI::Util::ProcessThread::pid_
protected

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

◆ status_

int UI::Util::ProcessThread::status_
protected

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


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