Base Framework
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Process Class Reference

Process. More...

#include <base/concurrency/Process.h>

Inherits Object.

Classes

class  Layout
 
class  ProcessException
 Exception raised by Process. More...
 
class  ProcessHandle
 
class  Times
 

Public Member Functions

 Process () noexcept
 
 Process (unsigned long id) noexcept
 
 Process (const Process &copy) noexcept
 
Processoperator= (const Process &assign) noexcept
 
unsigned long getId () noexcept
 
bool isValid () const noexcept
 
bool isAlive () const
 
String getName () const
 
void lock ()
 
int wait (unsigned int microseconds) noexcept
 
int wait ()
 
bool terminate (bool force=false)
 
Times getTimes () noexcept
 

Static Public Member Functions

static Layout getLayout () noexcept
 
static Process getProcess () noexcept
 
static Process getParentProcess () noexcept
 
static unsigned long getNumberOfConfiguredProcessors () noexcept
 
static unsigned long getNumberOfOnlineProcessors () noexcept
 
static bool supportsJobControl () noexcept
 
static Process fork ()
 
static int getPriority ()
 
static void setPriority (int priority)
 
static Process execute (const String &app)
 

Static Public Attributes

static const unsigned long INVALID = PrimitiveTraits<unsigned long>::MAXIMUM
 

Detailed Description

Process.

Process manipulation class.

Version
1.2

Constructor & Destructor Documentation

◆ Process() [1/3]

Process::Process ( )
noexcept

Initializes process as invalid.

◆ Process() [2/3]

Process::Process ( unsigned long  id)
inlinenoexcept

Initializes a process.

Parameters
idThe id of the process.

◆ Process() [3/3]

Process::Process ( const Process copy)
noexcept

Initializes process from other process.

Member Function Documentation

◆ execute()

static Process Process::execute ( const String app)
static

Executes the specified application (quotes are required if module contains a space). The return process has been locked.

Returns
The child process.

◆ fork()

static Process Process::fork ( )
static

Forks a child process.

Returns
The parent returns the child process. The child returns a process with id 0.

◆ getId()

unsigned long Process::getId ( )
inlinenoexcept

Returns the id of the process.

Examples
testsuite/Process.cpp.

◆ getLayout()

static Layout Process::getLayout ( )
inlinestaticnoexcept

Returns the layout of the process.

◆ getName()

String Process::getName ( ) const

Returns the name (path) of the process.

Examples
testsuite/Process.cpp.

◆ getNumberOfConfiguredProcessors()

static unsigned long Process::getNumberOfConfiguredProcessors ( )
inlinestaticnoexcept

Returns the number of configured processors in the system. It is legal for the operating system to lie about the true number of processors.

Returns
Returns 0 if the value cannot be determined.
Examples
testsuite/Process.cpp.

◆ getNumberOfOnlineProcessors()

static unsigned long Process::getNumberOfOnlineProcessors ( )
inlinestaticnoexcept

Returns the number of online processors in the system. It is legal for the operating system to lie about the true number of processors.

Returns
Returns 0 if the value cannot be determined.
Examples
testsuite/Process.cpp.

◆ getParentProcess()

static Process Process::getParentProcess ( )
staticnoexcept

Returns parent process. A process object with id 0 is returned when no parent is available.

Returns
Invalid process if not supported.
Examples
testsuite/Process.cpp.

◆ getPriority()

static int Process::getPriority ( )
static

Returns the priority of the process.

Examples
testsuite/Process.cpp.

◆ getProcess()

static Process Process::getProcess ( )
staticnoexcept

Returns this process.

Examples
testsuite/Process.cpp.

◆ getTimes()

Times Process::getTimes ( )
noexcept

Returns the current processing times (both user and system times).

◆ isAlive()

bool Process::isAlive ( ) const

Returns true if the process is alive. On some platforms this will only work if the process is a child process of the current process.

Examples
testsuite/Process.cpp.

◆ isValid()

bool Process::isValid ( ) const
inlinenoexcept

Returns true if the process id is invalid.

◆ lock()

void Process::lock ( )

Acquires a lock of the process which allows synchronization using the wait methods.

◆ operator=()

Process& Process::operator= ( const Process assign)
noexcept

Assignment of process with process.

◆ setPriority()

static void Process::setPriority ( int  priority)
static

Sets the priority of the process.

◆ supportsJobControl()

static bool Process::supportsJobControl ( )
inlinestaticnoexcept

Returns true if the system supports job control.

◆ terminate()

bool Process::terminate ( bool  force = false)

Requests the process to terminate.

Parameters
forceSpecifies whether to force the process to terminate. The default is false.
Returns
True if the signal was delivered.

◆ wait() [1/2]

int Process::wait ( )

Waits for the process to terminate.

Returns
The exit code (EXIT_CODE_INVALID if exit code is not available).

◆ wait() [2/2]

int Process::wait ( unsigned int  microseconds)
noexcept

Waits for the process to terminate. EXIT_CODE_CONFLICT is returned is the true exit code was EXIT_CODE_INVALID.

Parameters
microsecondsThe timeout period.
Returns
The exit code (EXIT_CODE_INVALID if exit code is not available or the timeout period expired).

Member Data Documentation

◆ INVALID

const unsigned long Process::INVALID = PrimitiveTraits<unsigned long>::MAXIMUM
static

Value which specifies an invalid process id.