#include <rw_lock.h>
Collaboration diagram for reader_writer_lock:

Public Member Functions | |
| reader_writer_lock () | |
| virtual | ~reader_writer_lock () |
| IMPLEMENT_CLASS_NAME ("reader_writer_lock") | |
| void | begin_read () |
| allows this thread to start reading the shared object. | |
| void | end_read () |
| indicates that this thread is done reading the object now. | |
| void | begin_write () |
| allows this thread to start writing the shared object. | |
| void | end_write () |
The object allows an unlimited number of simultaneous readers as long as there are no writers. Only one writer can operate on the object at a time. When there are no readers remaining, the writer may operate. When there are no writers remaining, the readers may operate. Starvation is not considered; if there are always readers vying for access to the list, then writers may starve. If a writer writes for an extended period of time, then readers may starve. These situations must be dealt with in the code using the rw lock.
Definition at line 33 of file rw_lock.h.
| reader_writer_lock::reader_writer_lock | ( | ) |
Definition at line 35 of file rw_lock.cpp.
| reader_writer_lock::~reader_writer_lock | ( | ) | [virtual] |
| reader_writer_lock::IMPLEMENT_CLASS_NAME | ( | "reader_writer_lock" | ) |
| void reader_writer_lock::begin_read | ( | ) |
allows this thread to start reading the shared object.
this will be paused if any thread currently owns a write lock on the object. any number of readers may begin reading if no writers are writing. every call to begin_read() must be matched with a call to end_read().
Definition at line 67 of file rw_lock.cpp.
References mutex_base::lock(), LOG, istring::SPRINTF, and mutex_base::unlock().
Referenced by nodes::safe_list::open_reader().
| void reader_writer_lock::end_read | ( | ) |
indicates that this thread is done reading the object now.
Definition at line 82 of file rw_lock.cpp.
References mutex_base::lock(), LOG, istring::SPRINTF, and mutex_base::unlock().
Referenced by nodes::safe_list::close_reader().
| void reader_writer_lock::begin_write | ( | ) |
allows this thread to start writing the shared object.
one writer may operate on the object at a time, but only if no readers are present. every call to begin_write() must eventually be followed by a call to end_write().
Definition at line 50 of file rw_lock.cpp.
References FUNCDEF, mutex_base::lock(), LOG, and istring::SPRINTF.
Referenced by nodes::safe_list::open_writer().
| void reader_writer_lock::end_write | ( | ) |
Definition at line 60 of file rw_lock.cpp.
References FUNCDEF, LOG, and mutex_base::unlock().
Referenced by nodes::safe_list::close_writer().
1.5.1