Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils::SameThreadGuard Class Reference

Same thread guard. More...

#include <same-thread-guard.hpp>

Public Member Functions

 SameThreadGuard ()
 
bool check ()
 On the first call it remembers the current thread id. More...
 
void reset ()
 Reset thread id. More...
 

Private Attributes

std::atomic< unsigned int > mThreadId
 

Detailed Description

Same thread guard.

There are two purposes of this guard:

  • reports invalid assumptions about synchronization needs (only in debug builds)
  • acts as an annotation in the source code about the thread safety

Usage example: ASSERT_SAME_THREAD(workerThreadGuard);

Constructor & Destructor Documentation

utils::SameThreadGuard::SameThreadGuard ( )

Member Function Documentation

bool utils::SameThreadGuard::check ( )

On the first call it remembers the current thread id.

On the next call it verifies that current thread is the same as before.

void utils::SameThreadGuard::reset ( )

Reset thread id.

Member Data Documentation

std::atomic<unsigned int> utils::SameThreadGuard::mThreadId
private

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