Share via


reader_writer_lock Class

A writer-preference queue-based reader-writer lock with local only spinning. The lock grants first in - first out (FIFO) access to writers and starves readers under a continuous load of writers.

class reader_writer_lock;

Members

Public Classes

Name

Description

reader_writer_lock::scoped_lock Class

An exception safe RAII wrapper that can be used to acquire reader_writer_lock lock objects as a writer.

reader_writer_lock::scoped_lock_read Class

An exception safe RAII wrapper that can be used to acquire reader_writer_lock lock objects as a reader.

Public Constructors

Name

Description

reader_writer_lock::reader_writer_lock Constructor

Constructs a new reader_writer_lock object.

reader_writer_lock::~reader_writer_lock Destructor

Destroys the reader_writer_lock object.

Public Methods

Name

Description

reader_writer_lock::lock Method

Acquires the reader-writer lock as a writer.

reader_writer_lock::lock_read Method

Acquires the reader-writer lock as a reader. If there are writers, active readers have to wait until they are done. The reader simply registers an interest in the lock and waits for writers to release it.

reader_writer_lock::try_lock Method

Attempts to acquire the reader-writer lock as a writer without blocking.

reader_writer_lock::try_lock_read Method

Attempts to acquire the reader-writer lock as a reader without blocking.

reader_writer_lock::unlock Method

Unlocks the reader-writer lock based on who locked it, reader or writer.

Remarks

For more information, see Synchronization Data Structures.

Inheritance Hierarchy

reader_writer_lock

Requirements

Header: concrt.h

Namespace: Concurrency

See Also

Reference

Concurrency Namespace

critical_section Class