c++-gtk-utils
Public Member Functions | Static Public Member Functions
Cgu::Thread::CancelBlock Class Reference

A class enabling the cancellation state of a thread to be controlled. More...

#include <c++-gtk-utils/thread.h>

List of all members.

Public Member Functions

 CancelBlock (const CancelBlock &)
CancelBlockoperator= (const CancelBlock &)
int restore (int &old_state)
int restore ()
 CancelBlock (bool blocking=true)
 ~CancelBlock ()

Static Public Member Functions

static int block (int &old_state)
static int block ()
static int unblock (int &old_state)
static int unblock ()

Detailed Description

A class enabling the cancellation state of a thread to be controlled.

A class enabling the cancellation state of a thread to be controlled, so as to provide exception safe cancellation state changes. When the object goes out of scope, cancellation state is returned to the state it was in prior to its construction.


Constructor & Destructor Documentation

Cgu::Thread::CancelBlock::CancelBlock ( const CancelBlock )

This class cannot be copied. The copy constructor is deleted.

Cgu::Thread::CancelBlock::CancelBlock ( bool  blocking = true)

The constructor will not throw.

Parameters:
blockingWhether the CancelBlock object should start in blocking mode.
Cgu::Thread::CancelBlock::~CancelBlock ( )
inline

The destructor will put the thread in the cancellation state that it was in immediately before the CancelBlock object was constructed (which might be blocking). It will not throw.


Member Function Documentation

static int Cgu::Thread::CancelBlock::block ( int &  old_state)
inlinestatic

Makes the thread uncancellable, even if the code passes through a cancellation point, while the CancelBlock object exists (when the CancelBlock object ceases to exist, cancellation state is returned to the state prior to it being constructed). It should only be called by the thread which created the CancelBlock object. This method will not throw.

Parameters:
old_stateIndicates the cancellation state of the calling thread immediately before this call to block() was made, either PTHREAD_CANCEL_ENABLE (if the thread was previously cancellable) or PTHREAD_CANCEL_DISABLE (if this call did nothing because the thread was already uncancellable).
Returns:
0 if successful, else a value other than 0.
static int Cgu::Thread::CancelBlock::block ( )
inlinestatic

Makes the thread uncancellable, even if the code passes through a cancellation point, while the CancelBlock object exists (when the CancelBlock object ceases to exist, cancellation state is returned to the state prior to it being constructed). It should only be called by the thread which created the CancelBlock object. This method will not throw.

Returns:
0 if successful, else a value other than 0.
CancelBlock& Cgu::Thread::CancelBlock::operator= ( const CancelBlock )

This class cannot be copied. The assignment operator is deleted.

int Cgu::Thread::CancelBlock::restore ( int &  old_state)
inline

Restores cancellation state to the state it was in immediately before this CancelBlock object was constructed. It should only be called by the thread which created the CancelBlock object. This method will not throw.

Parameters:
old_stateIndicates the cancellation state of the calling thread immediately before this call to restore() was made, either PTHREAD_CANCEL_DISABLE (if the thread was previously uncancellable) or PTHREAD_CANCEL_ENABLE (if this thread was previously cancellable).
Returns:
0 if successful, else a value other than 0.
int Cgu::Thread::CancelBlock::restore ( )
inline

Restores cancellation state to the state it was in immediately before this CancelBlock object was constructed. It should only be called by the thread which created the CancelBlock object. This method will not throw.

Returns:
0 if successful, else a value other than 0.
static int Cgu::Thread::CancelBlock::unblock ( int &  old_state)
inlinestatic

Makes the thread cancellable while the CancelBlock object exists (when the CancelBlock object ceases to exist, cancellation state is returned to the state prior to it being constructed). It should only be called by the thread which created the CancelBlock object. This method will not throw.

Parameters:
old_stateIndicates the cancellation state of the calling thread immediately before this call to unblock() was made, either PTHREAD_CANCEL_DISABLE (if the thread was previously uncancellable) or PTHREAD_CANCEL_ENABLE (if this call did nothing because the thread was already cancellable).
Returns:
0 if successful, else a value other than 0.
static int Cgu::Thread::CancelBlock::unblock ( )
inlinestatic

Makes the thread cancellable while the CancelBlock object exists (when the CancelBlock object ceases to exist, cancellation state is returned to the state prior to it being constructed). It should only be called by the thread which created the CancelBlock object. This method will not throw.

Returns:
0 if successful, else a value other than 0.

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