Rapicorn - Experimental UI Toolkit - Source Code  13.07.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Classes | Namespaces | Defines | Functions | Variables
thread.hh File Reference
#include <rcore/utilities.hh>
#include <rcore/threadlib.hh>
#include <thread>
#include <list>

Go to the source code of this file.

Classes

struct  Rapicorn::RECURSIVE_LOCK
class  Rapicorn::Mutex
 The Mutex synchronization primitive is a thin wrapper around std::mutex. More...
class  Rapicorn::Spinlock
 The Spinlock uses low-latency busy spinning to acquire locks. More...
class  Rapicorn::RWLock
 The RWLock allows multiple readers to simultaneously access a critical code section or one writer. More...
struct  Rapicorn::ThreadInfo
 Class keeping information per Thread. More...
struct  Rapicorn::AUTOMATIC_LOCK
struct  Rapicorn::BALANCED_LOCK
class  Rapicorn::ScopedLock< MUTEX >
 The ScopedLock is a scope based lock ownership wrapper. More...
class  Rapicorn::Cond
 The Cond synchronization primitive is a thin wrapper around pthread_cond_wait(). More...
struct  Rapicorn::Atomic< char >
 Atomic char type. More...
struct  Rapicorn::Atomic< int8 >
 Atomic int8 type. More...
struct  Rapicorn::Atomic< uint8 >
 Atomic uint8 type. More...
struct  Rapicorn::Atomic< int32 >
 Atomic int32 type. More...
struct  Rapicorn::Atomic< uint32 >
 Atomic uint32 type. More...
struct  Rapicorn::Atomic< int64 >
 Atomic int64 type. More...
struct  Rapicorn::Atomic< uint64 >
 Atomic uint64 type. More...
class  Rapicorn::Atomic< V * >
 Atomic pointer type. More...
class  Rapicorn::Exclusive< Type >
 Exclusive<> is a type wrapper that provides non-racy atomic access to a copyable Type. More...
class  Rapicorn::AsyncBlockingQueue< Value >
 This is a thread-safe asyncronous queue which blocks in pop() until data is provided through push(). More...
class  Rapicorn::AsyncNotifyingQueue< Value >
 This is a thread-safe asyncronous queue which returns 0 from pop() until data is provided through push(). More...
class  Rapicorn::AsyncRingBuffer< T >
 This is a thread-safe lock-free ring buffer of fixed size. More...

Namespaces

namespace  Rapicorn
 

The Rapicorn namespace encompasses core utilities and toolkit functionality.


namespace  Rapicorn::ThisThread
 

The ThisThread namespace provides functions for the current thread of execution.


Defines

#define do_once
 The do_once statement preceeds code blocks to ensure that a critical section is executed atomically and at most once.

Functions

String Rapicorn::ThisThread::name ()
 Get thread name.
int Rapicorn::ThisThread::online_cpus ()
 This function may be called before Rapicorn is initialized.
int Rapicorn::ThisThread::affinity ()
 This function may be called before Rapicorn is initialized.
void Rapicorn::ThisThread::affinity (int cpu)
 This function may be called before Rapicorn is initialized.
int Rapicorn::ThisThread::thread_pid ()
 Get the current threads's thread ID (TID). For further details, see gettid().
int Rapicorn::ThisThread::process_pid ()
 Get the process ID (PID). For further details, see getpid().
void Rapicorn::ThisThread::yield ()
 Relinquish the processor to allow execution of other threads. For further details, see std::this_thread::yield().
std::thread::id Rapicorn::ThisThread::get_id ()
 Returns the pthread_t id for the current thread. For further details, see std::this_thread::get_id().
template<class Rep , class Period >
void Rapicorn::ThisThread::sleep_for (std::chrono::duration< Rep, Period > sleep_duration)
 Sleep for sleep_duration has been reached. For further details, see std::this_thread::sleep_for().
template<class Clock , class Duration >
void Rapicorn::ThisThread::sleep_until (const std::chrono::time_point< Clock, Duration > &sleep_time)
 Sleep until sleep_time has been reached. For further details, see std::this_thread::sleep_until().

Variables

struct Rapicorn::RECURSIVE_LOCK Rapicorn::RECURSIVE_LOCK
 Flag for recursive Mutex initialization.
struct Rapicorn::AUTOMATIC_LOCK Rapicorn::AUTOMATIC_LOCK
 Flag for automatic locking of a ScopedLock<Mutex>.
struct Rapicorn::BALANCED_LOCK Rapicorn::BALANCED_LOCK
 Flag for balancing unlock/lock in a ScopedLock<Mutex>.

Detailed Description


Define Documentation

#define do_once

The do_once statement preceeds code blocks to ensure that a critical section is executed atomically and at most once.

Example:

static const char*
startup_message ()
{
  // A global variable that needs one time initialization
  static char text_variable[1024];

  // Initialize text_variable only once
  do_once
    {
      snprintf (text_variable, sizeof (text_variable), "Initialized at: %zu", size_t (timestamp_realtime()));
    }

  // Always returns the same text
  return text_variable;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines