PConcurrentThread Class Reference

Detailed Description

The PConcurrentThread class represents a thread, a sequence of instructions that can be executed concurrently with other such sequences in multi-threading environments, while sharing a same address space.

Multiple threads can exist within one process, executing concurrently and sharing resources such as memory.

You can either create a thread from a single function or an instance of any class implementing PRunnable.

Definition at line 87 of file PConcurrentThread.h.

#include <PConcurrentThread.h>

Constructor & Destructor Documentation

◆ PConcurrentThread() [1/4]

PConcurrentThread::PConcurrentThread ( )

Constructs a new thread instance that refers to NOT-A-THREAD.

◆ PConcurrentThread() [2/4]

PConcurrentThread::PConcurrentThread ( void(*)()  f)

Constructs a new concurrent thread instance which starts running the passed function and ends when the function returns.

◆ PConcurrentThread() [3/4]

PConcurrentThread::PConcurrentThread ( PRunnable r)

Constructs a new concurrent thread instance which starts running the specified PRunnable object (call the Run() method) and ends when Run() returns.

◆ PConcurrentThread() [4/4]

PConcurrentThread::PConcurrentThread ( const PConcurrentThread other)

Constructs a shared copy of other.

◆ ~PConcurrentThread()

virtual PConcurrentThread::~PConcurrentThread ( )

Destroys this object.

Member Function Documentation

◆ GetNumAvailableHardwareCores()

static papillon::int32 PConcurrentThread::GetNumAvailableHardwareCores ( )

Returns the number of physical cores available on the current system.

In contrast to GetNumAvailableHardwareThreads() it does not return the number of virtual cores, but it counts only physical cores.

◆ GetNumAvailableHardwareThreads()

static papillon::int32 PConcurrentThread::GetNumAvailableHardwareThreads ( )

Returns the number of hardware threads available on the current system (e.g.

number of CPUs or cores or hyper-threading units).

◆ GetThreadId()

static papillon::uint64 PConcurrentThread::GetThreadId ( )

Returns the current thread id.

◆ Join()

void PConcurrentThread::Join ( )

Waits for that thread of execution to complete; do nothing is the thread is empty.

◆ operator=()

PConcurrentThread& PConcurrentThread::operator= ( const PConcurrentThread other)

Performs a shared copy of other to this object.

◆ Sleep()

static void PConcurrentThread::Sleep ( papillon::int32  timeMs)

Suspends this thread until the duration specified by timeMs (milliseconds) has elapsed.

◆ TryJoin()

PResult PConcurrentThread::TryJoin ( papillon::int32  timeMs)

Waits for that thread of execution to complete up to timeMs milliseconds; do nothing is the thread is empty.

Returns PResult::C_OK if the thread has joined in the specified period, another result otherwise.