Geogram  Version 1.9.0
A programming library of geometric algorithms
GEO::Thread Class Referenceabstract

Platform-independent base class for running threads. More...

#include <geogram/basic/process.h>

Inheritance diagram for GEO::Thread:
GEO::Counted

Public Member Functions

 Thread ()
 Thread constructor.
 
virtual void run ()=0
 Starts the thread execution.
 
index_t id () const
 Gets the identifier of this thread. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Static Public Member Functions

static Threadcurrent ()
 Gets the current thread. More...
 
static index_t current_id ()
 Gets the identifier of the current thread. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Protected Member Functions

 ~Thread () override
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Friends

class ThreadManager
 

Detailed Description

Platform-independent base class for running threads.

A Thread object manages one thread of control within the program. Threads begin executing with run(). Operational threads can be created by creating a derived class and reimplement function run().

Threads are reference-counted objects. Their allocation and destruction can be automatically managed with Thread_var.

Definition at line 66 of file process.h.

Constructor & Destructor Documentation

◆ ~Thread()

GEO::Thread::~Thread ( )
overrideprotected

Thread destructor

Member Function Documentation

◆ current()

static Thread* GEO::Thread::current ( )
static

Gets the current thread.

Returns
A pointer to the instance of the currently running thread. If not running multiple threads, returns nullptr.

◆ current_id()

static index_t GEO::Thread::current_id ( )
inlinestatic

Gets the identifier of the current thread.

Returns
the identifier of the current thread, i.e. an unsigned integer in the range [0, N-1] where N denotes the number of currently running threads. If not running multiple threads, returns 0.

Definition at line 107 of file process.h.

◆ id()

index_t GEO::Thread::id ( ) const
inline

Gets the identifier of this thread.

Returns
the identifier of the thread, i.e. an unsigned integer in the range [0, N-1] where N denotes the number of currently running threads.

Definition at line 87 of file process.h.


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