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 126 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 131 of file reader_writer_lock.h.

131  {
133  }
void __TBB_EXPORTED_METHOD internal_construct(reader_writer_lock &)
void __TBB_EXPORTED_METHOD lock()
Acquires the reader_writer_lock for write.

References internal_construct(), and tbb::interface5::reader_writer_lock::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 136 of file reader_writer_lock.h.

136  {
138  }

References internal_destroy().

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 328 of file reader_writer_lock.cpp.

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

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

Member Function Documentation

◆ internal_construct()

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

Definition at line 315 of file reader_writer_lock.cpp.

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

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

Referenced by scoped_lock_read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internal_destroy()

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

Definition at line 340 of file reader_writer_lock.cpp.

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

References tbb::interface5::reader_writer_lock::invalid.

Referenced by ~scoped_lock_read().

Here is the caller graph for this function:

◆ operator delete()

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

Definition at line 143 of file reader_writer_lock.h.

143  {
145  }
void const char const char int ITT_FORMAT __itt_group_sync p
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.

References tbb::internal::deallocate_via_handler_v3(), and 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 140 of file reader_writer_lock.h.

140  {
142  }
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
void const char const char int ITT_FORMAT __itt_group_sync s

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

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 128 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 149 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 151 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

Status flag of the thread associated with this node.

Definition at line 153 of file reader_writer_lock.h.

Referenced by scoped_lock_read(), and tbb::interface5::reader_writer_lock::start_read().


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.