GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
graphlab::thread Class Reference

#include <graphlab/parallel/pthread_tools.hpp>

List of all members.

Classes

class  tls_data

Public Member Functions

 thread (size_t thread_id=0)
void launch (const boost::function< void(void)> &spawn_routine)
void launch (const boost::function< void(void)> &spawn_routine, size_t cpu_id)
void join ()
bool active () const
 Returns true if the thread is still running.
pthread_t pthreadid ()
 Returns the pthread thread id.

Static Public Member Functions

static tls_dataget_tls_data ()
 Static helper routines.
static size_t thread_id ()
static void set_thread_id (size_t t)
static anyget_local (const size_t &id)
static bool contains (const size_t &id)
static size_t erase (const size_t &id)
static void join (thread &other)
static void thread_destroy_callback ()
static void set_thread_destroy_callback (void(*callback)())
static size_t cpu_count ()

Detailed Description

A collection of routines for creating and managing threads.

The thread object performs limited exception forwarding. exception throws within a thread of type const char* will be caught and forwarded to the join() function. If the call to join() is wrapped by a try-catch block, the exception will be caught safely and thread cleanup will be completed properly.

Definition at line 720 of file pthread_tools.hpp.


Constructor & Destructor Documentation

graphlab::thread::thread ( size_t  thread_id = 0)
inline

Creates a thread with a user-defined associated thread ID

Definition at line 822 of file pthread_tools.hpp.


Member Function Documentation

static bool graphlab::thread::contains ( const size_t &  id)
inlinestatic

Check to see if there is an entry in the local map

Definition at line 773 of file pthread_tools.hpp.

size_t graphlab::thread::cpu_count ( )
static

Return the number processing units (individual cores) on this system

Definition at line 161 of file pthread_tools.cpp.

static size_t graphlab::thread::erase ( const size_t &  id)
inlinestatic

Removes the entry from the local map.

Returns:
number of elements erased.

Definition at line 781 of file pthread_tools.hpp.

static any& graphlab::thread::get_local ( const size_t &  id)
inlinestatic

Get a reference to an any object

Definition at line 766 of file pthread_tools.hpp.

thread::tls_data & graphlab::thread::get_tls_data ( )
static

Static helper routines.

Get the thread specific data associated with this thread

This function tries to get the thread specific data. If no thread specific data has been associated with the thread than it is created.

Definition at line 82 of file pthread_tools.cpp.

void graphlab::thread::join ( thread other)
static

This static method joins the invoking thread with the other thread object. This thread will not return from the join routine until the other thread complets it run.

Definition at line 138 of file pthread_tools.cpp.

void graphlab::thread::join ( )
inline

Join the calling thread with this thread. const char* exceptions thrown by the thread is forwarded to the join() function.

Definition at line 853 of file pthread_tools.hpp.

void graphlab::thread::launch ( const boost::function< void(void)> &  spawn_routine)

execute this function to spawn a new thread running spawn_function routine

Definition at line 197 of file pthread_tools.cpp.

void graphlab::thread::launch ( const boost::function< void(void)> &  spawn_routine,
size_t  cpu_id 
)

Same as launch() except that you can specify a CPU on which to run the thread. This only currently supported in Linux and if invoked on a non Linux based system this will be equivalent to start().

Definition at line 226 of file pthread_tools.cpp.

static void graphlab::thread::set_thread_id ( size_t  t)
inlinestatic

Set the id of the calling thread. This will typically be the index in the thread group. Between 0 to ncpus.

Definition at line 761 of file pthread_tools.hpp.

static size_t graphlab::thread::thread_id ( )
inlinestatic

Get the id of the calling thread. This will typically be the index in the thread group. Between 0 to ncpus.

Definition at line 757 of file pthread_tools.hpp.


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