template class Poco::ThreadLocal

Overview

This template is used to declare type safe thread local variables. More…

#include <ThreadLocal.h>

template <class C>
class ThreadLocal
{
public:
    // methods

    C*
    operator->();

    C&
    operator*();

    C&
    get();
};

Detailed Documentation

This template is used to declare type safe thread local variables.

It can basically be used like a smart pointer class with the special feature that it references a different object in every thread. The underlying object will be created when it is referenced for the first time. See the NestedDiagnosticContext class for an example how to use this template. Every thread only has access to its own thread local data. There is no way for a thread to access another thread’s local data.

Methods

C&
operator*()

“Dereferences” the smart pointer and returns a reference to the underlying data object.

The reference can be used to modify the object.

C&
get()

Returns a reference to the underlying data object.

The reference can be used to modify the object.