Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface5::reader_writer_lock::scoped_lock_read Class Reference

The scoped lock pattern for read locks. More...

#include <reader_writer_lock.h>

Inheritance diagram for tbb::interface5::reader_writer_lock::scoped_lock_read:
Collaboration diagram for tbb::interface5::reader_writer_lock::scoped_lock_read:

Public Member Functions

 scoped_lock_read (reader_writer_lock &lock)
 Construct with blocking attempt to acquire read lock on the passed-in lock. More...
 
 ~scoped_lock_read ()
 Destructor, releases the read lock. More...
 
voidoperator new (size_t s)
 
void operator delete (void *p)
 

Private Member Functions

 scoped_lock_read ()
 Construct scoped_lock_read that is not holding lock. More...
 
void __TBB_EXPORTED_METHOD internal_construct (reader_writer_lock &)
 
void __TBB_EXPORTED_METHOD internal_destroy ()
 
- Private Member Functions inherited from tbb::internal::no_copy
 no_copy ()
 Allow default construction. More...
 

Private Attributes

reader_writer_lockmutex
 The pointer to the mutex to lock. More...
 
scoped_lock_readnext
 The next queued competitor for the mutex. More...
 
atomic< status_tstatus
 Status flag of the thread associated with this node. More...
 

Friends

class reader_writer_lock
 

Detailed Description

The scoped lock pattern for read locks.

Definition at line 122 of file reader_writer_lock.h.

Constructor & Destructor Documentation

◆ scoped_lock_read() [1/2]

tbb::interface5::reader_writer_lock::scoped_lock_read::scoped_lock_read ( reader_writer_lock lock)
inline

Construct with blocking attempt to acquire read lock on the passed-in lock.

Definition at line 127 of file reader_writer_lock.h.

References tbb::interface5::reader_writer_lock::scoped_lock::internal_construct().

127  {
129  }
void __TBB_EXPORTED_METHOD lock()
Acquires the reader_writer_lock for write.
void __TBB_EXPORTED_METHOD internal_construct(reader_writer_lock &)
Here is the call graph for this function:

◆ ~scoped_lock_read()

tbb::interface5::reader_writer_lock::scoped_lock_read::~scoped_lock_read ( )
inline

Destructor, releases the read lock.

Definition at line 132 of file reader_writer_lock.h.

References tbb::interface5::reader_writer_lock::scoped_lock::internal_destroy().

132  {
134  }
Here is the call graph for this function:

◆ scoped_lock_read() [2/2]

tbb::interface5::reader_writer_lock::scoped_lock_read::scoped_lock_read ( )
inlineprivate

Construct scoped_lock_read that is not holding lock.

Definition at line 324 of file reader_writer_lock.cpp.

References status, and tbb::interface5::reader_writer_lock::waiting.

324  : mutex(NULL), next(NULL) {
325  status = waiting;
326 }
atomic< status_t > status
Status flag of the thread associated with this node.
scoped_lock_read * next
The next queued competitor for the mutex.
reader_writer_lock * mutex
The pointer to the mutex to lock.

Member Function Documentation

◆ internal_construct()

void tbb::interface5::reader_writer_lock::scoped_lock_read::internal_construct ( reader_writer_lock lock)
private

Definition at line 311 of file reader_writer_lock.cpp.

References tbb::internal::eid_improper_lock, tbb::interface5::reader_writer_lock::lock(), tbb::interface5::reader_writer_lock::scoped_lock::next, tbb::interface5::reader_writer_lock::scoped_lock::status, tbb::internal::throw_exception(), and tbb::interface5::reader_writer_lock::waiting.

311  {
312  mutex = &lock;
313  next = NULL;
314  status = waiting;
315  if (mutex->is_current_writer()) { // recursive lock attempt
316  // we don't support writer->reader downgrade; throw exception
318  }
319  else { // this thread holds no locks
320  mutex->start_read(this);
321  }
322 }
bool is_current_writer()
Checks if current thread holds write lock.
atomic< status_t > status
Status flag of the thread associated with this node.
void __TBB_EXPORTED_METHOD lock()
Acquires the reader_writer_lock for write.
scoped_lock_read * next
The next queued competitor for the mutex.
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
void start_read(scoped_lock_read *)
Attempts to acquire read lock.
reader_writer_lock * mutex
The pointer to the mutex to lock.
Here is the call graph for this function:

◆ internal_destroy()

void tbb::interface5::reader_writer_lock::scoped_lock_read::internal_destroy ( )
private

Definition at line 336 of file reader_writer_lock.cpp.

References tbb::interface5::reader_writer_lock::invalid, and status.

336  {
337  if (mutex)
338  mutex->end_read();
339  status = invalid;
340 }
atomic< status_t > status
Status flag of the thread associated with this node.
void end_read()
Relinquishes read lock by decrementing counter; last reader wakes pending writer. ...
reader_writer_lock * mutex
The pointer to the mutex to lock.

◆ operator delete()

void tbb::interface5::reader_writer_lock::scoped_lock_read::operator delete ( void p)
inline

Definition at line 139 of file reader_writer_lock.h.

References tbb::internal::deallocate_via_handler_v3(), and p.

139  {
141  }
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.
void const char const char int ITT_FORMAT __itt_group_sync p
Here is the call graph for this function:

◆ operator new()

void* tbb::interface5::reader_writer_lock::scoped_lock_read::operator new ( size_t  s)
inline

Definition at line 136 of file reader_writer_lock.h.

References tbb::internal::allocate_via_handler_v3(), and s.

136  {
138  }
void const char const char int ITT_FORMAT __itt_group_sync s
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
Here is the call graph for this function:

Friends And Related Function Documentation

◆ reader_writer_lock

friend class reader_writer_lock
friend

Definition at line 124 of file reader_writer_lock.h.

Member Data Documentation

◆ mutex

reader_writer_lock* tbb::interface5::reader_writer_lock::scoped_lock_read::mutex
private

The pointer to the mutex to lock.

Definition at line 145 of file reader_writer_lock.h.

◆ next

scoped_lock_read* tbb::interface5::reader_writer_lock::scoped_lock_read::next
private

The next queued competitor for the mutex.

Definition at line 147 of file reader_writer_lock.h.

Referenced by tbb::interface5::reader_writer_lock::start_read().

◆ status

atomic<status_t> tbb::interface5::reader_writer_lock::scoped_lock_read::status
private

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

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.