glibmm  2.33.2
Public Types | Public Member Functions | Static Public Member Functions
Glib::Threads::Private Class Reference

Thread-local data pointer. More...

#include <glibmm/threads.h>

List of all members.

Public Types

typedef void(* DestructorFunc )(void*)

Public Member Functions

 Private (DestructorFunc destructor_func=&Private< T >::delete_ptr)
 Constructor.
T* get ()
 Gets the pointer stored in the calling thread.
void set (T* data)
 Sets the pointer in the calling thread without calling destructor_func().
void replace (T* data)
 Sets the pointer in the calling thread and calls destructor_func().
GPrivate* gobj ()

Static Public Member Functions

static void delete_ptr (void* data)
 Deletes static_cast<T*>(data)

Detailed Description

Thread-local data pointer.

It is recommended that all instances of this class are statically allocated. The first time an instance is used (get(), set() or replace() is called) gtk+ allocates a scarce OS resource that cannot be deallocated.


Member Typedef Documentation


Constructor & Destructor Documentation

Glib::Threads::Private::Private ( DestructorFunc  destructor_func = &Private< T >::delete_ptr) [inline, explicit]

Constructor.

Parameters:
destructor_funcFunction pointer, or 0. If destructor_func is not 0 and the stored data pointer is not 0, this function is called when replace() is called and when the thread exits.

Member Function Documentation

static void Glib::Threads::Private::delete_ptr ( void *  data) [static]

Deletes static_cast<T*>(data)

T* Glib::Threads::Private::get ( ) [inline]

Gets the pointer stored in the calling thread.

Returns:
If no value has yet been set in this thread, 0 is returned.
GPrivate* Glib::Threads::Private::gobj ( ) [inline]
void Glib::Threads::Private::replace ( T *  data) [inline]

Sets the pointer in the calling thread and calls destructor_func().

If a function pointer (and not 0) was specified in the constructor, and the stored data pointer before the call to replace() is not 0, then destructor_func() is called with this old pointer value.

Since glibmm 2.32:
void Glib::Threads::Private::set ( T *  data) [inline]

Sets the pointer in the calling thread without calling destructor_func().