ivutils
Loading...
Searching...
No Matches
GlobalPointer< T > Class Template Reference

Pointer to some global data we want to access from all threads. More...

#include <omp_pointers.h>

Public Member Functions

GuardingPointer operator-> ()
 On access should return the special type of reference that is locking object while present.
 

Detailed Description

template<typename T>
class GlobalPointer< T >

Pointer to some global data we want to access from all threads.

Technically doesn't work like a pointer. Every access returns GuardingPointer that contains LockGuard for the lock in the GlobalPointer. Thus calling some member function with -> operator or accessing the data should be atomic. Nested lock guarantees that we can access underling data multiple times from the same thread. While GuardingPointer exists no other thread can access the data through the GlobalPointer so make sure it existence is as short as possible. In most cases it's better to use GuardingPointer only as some temporary object. Do not forward data from GuardingPointer into functions as T* since it will unlock the lock after arguments of a function are calculated.


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