|
The Pedigree Project 0.1
|
#include <Buffer.h>
Inheritance diagram for Buffer< T, allowShortOperation >:
Collaboration diagram for Buffer< T, allowShortOperation >:Classes | |
| class | ActiveOperation |
| struct | Segment |
Public Member Functions | |
| Buffer (size_t bufferSize) | |
| size_t | write (const T *buffer, size_t count, bool block=true) |
| size_t | writeAvailable (const T *buffer, size_t count, bool atomic=false) |
| size_t | writeAtomic (const T *buffer, size_t count, bool block=true) |
| bool | tryWrite (const T *buffer, size_t count) |
| size_t | read (T *buffer, size_t count, bool block=true) |
| void | disableWrites () |
| void | disableReads () |
| bool | enableWrites () |
| bool | enableReads () |
| size_t | getDataSize () |
| size_t | getSize () |
| bool | canWrite (bool block) |
| bool | canRead (bool block) |
| uint64_t | readableGeneration () const |
| uint64_t | writableGeneration () const |
| void | wipe () |
| void | monitor (Thread *pThread, Event *pEvent) |
| void | monitor (Semaphore *pSemaphore) |
| void | cullMonitorTargets (Thread *pThread) |
| void | cullMonitorTargets (Semaphore *pSemaphore) |
| void | cullMonitorTargets (Event *pEvent) |
Private Member Functions | |
| WITHOUT_IMPLICIT_CONSTRUCTORS (Buffer) | |
| bool | beginOperation () |
| void | endOperation () |
| void | notifyMonitors () |
| void | notifyMonitorsLocked () |
| size_t | writeLocked (const T *buffer, size_t count) |
| void | addSegment (const T *buffer, size_t count) |
Private Attributes | |
| size_t | m_BufferSize |
| size_t | m_DataSize |
| Atomic< uint64_t > | m_ReadableGeneration |
| Atomic< uint64_t > | m_WritableGeneration |
| Mutex | m_Lock |
| ConditionVariable | m_WriteCondition |
| ConditionVariable | m_ReadCondition |
| ConditionVariable | m_DrainCondition |
| List< Segment * > | m_Segments |
| BufferMonitors | m_Monitors |
| bool | m_bCanRead |
| bool | m_bCanWrite |
| bool | m_bClosing |
| size_t | m_ActiveOperations |
Static Private Attributes | |
| static const size_t | m_SegmentSize = 32768 |
Friends | |
| class | UnixSocket |
Provides a buffer of a specific size and utility functions for integration with e.g. File or other kernel systems.
allowShortOperation defines the action to take on overflow. If true, the buffer's write() operation is permitted to return a size less than requested if the buffer would overflow. Otherwise, the implementation is required to block until bytes are present (unless blocking has been explicitly denied).
Note that an attempt to read when writing is disabled that would block will always return the number of bytes read so far (or zero if none yet). The same is true for an attempt to write when reading is disabled if that would block.
|
private |
Create a new segment with the given data.
Definition at line 727 of file Buffer.cc.
References Buffer< T, allowShortOperation >::Segment::data, and Buffer< T, allowShortOperation >::Segment::size.
|
private |
| bool Buffer< T, allowShortOperation >::canRead | ( | bool | block | ) |
Check if the buffer can be read from.
Definition at line 525 of file Buffer.cc.
References LockGuard< T >::disown(), and ConditionVariable::mutexAcquired().
Referenced by ConsoleFile::select(), ConsolePhysicalFile::select(), PsAuxFile::select(), UnixSocket::select(), TextIO::select(), InputFile::select(), EvdevFile::select(), and TextIO::writeStr().
Here is the caller graph for this function:| bool Buffer< T, allowShortOperation >::canWrite | ( | bool | block | ) |
Check if the buffer can be written to.
Definition at line 491 of file Buffer.cc.
References LockGuard< T >::disown(), and ConditionVariable::mutexAcquired().
Referenced by ConsoleFile::inputLineDiscipline(), ConsoleFile::select(), PsAuxFile::select(), and TextIO::select().
Here is the caller graph for this function:| void Buffer< T, allowShortOperation >::disableReads | ( | ) |
| void Buffer< T, allowShortOperation >::disableWrites | ( | ) |
Disable further writes to the buffer. This wakes all operations whose wait predicate can no longer succeed.
Definition at line 406 of file Buffer.cc.
Referenced by Ps2Controller::uninitialise().
Here is the caller graph for this function:| bool Buffer< T, allowShortOperation >::enableReads | ( | ) |
| bool Buffer< T, allowShortOperation >::enableWrites | ( | ) |
Enable writes to the buffer.
Definition at line 438 of file Buffer.cc.
Referenced by Ps2Controller::initialise3().
Here is the caller graph for this function:
|
private |
| size_t Buffer< T, allowShortOperation >::getDataSize | ( | ) |
| size_t Buffer< T, allowShortOperation >::getSize | ( | ) |
|
private |
|
private |
| size_t Buffer< T, allowShortOperation >::read | ( | T * | buffer, |
| size_t | count, | ||
| bool | block = true |
||
| ) |
Read
| count | values into |
| buffer,optionally | blocking if no more values are available to be read yet. |
Definition at line 296 of file Buffer.cc.
References Buffer< T, allowShortOperation >::Segment::data, ConditionVariable::mutexAcquired(), Buffer< T, allowShortOperation >::Segment::reader, and Buffer< T, allowShortOperation >::Segment::size.
Referenced by ConsoleFile::inputLineDiscipline(), PsAuxFile::readBytewise(), TextIO::readBytewise(), InputFile::readBytewise(), EvdevFile::readBytewise(), Ps2Controller::readFirstPort(), and Ps2Controller::readSecondPort().
Here is the caller graph for this function:| uint64_t Buffer< T, allowShortOperation >::readableGeneration | ( | ) | const |
Rising-edge sequences updated atomically with the protected predicates.
Definition at line 559 of file Buffer.cc.
Referenced by UnixSocket::readinessGenerations().
Here is the caller graph for this function:| bool Buffer< T, allowShortOperation >::tryWrite | ( | const T * | buffer, |
| size_t | count | ||
| ) |
| void Buffer< T, allowShortOperation >::wipe | ( | ) |
Wipes the buffer.
Definition at line 569 of file Buffer.cc.
Referenced by Ps2Controller::initialise3().
Here is the caller graph for this function:| uint64_t Buffer< T, allowShortOperation >::writableGeneration | ( | ) | const |
| size_t Buffer< T, allowShortOperation >::write | ( | const T * | buffer, |
| size_t | count, | ||
| bool | block = true |
||
| ) |
Write
| count | values from |
| buffer,optionally | blocking before writing if there is insufficient space. |
Definition at line 103 of file Buffer.cc.
Referenced by ConsoleFile::inputLineDiscipline(), and TextIO::writeStr().
Here is the caller graph for this function:| size_t Buffer< T, allowShortOperation >::writeAtomic | ( | const T * | buffer, |
| size_t | count, | ||
| bool | block = true |
||
| ) |
| size_t Buffer< T, allowShortOperation >::writeAvailable | ( | const T * | buffer, |
| size_t | count, | ||
| bool | atomic = false |
||
| ) |
Waits for buffer lock ownership, then writes up to the currently available capacity without waiting for a reader. Returns zero if either side closed. When atomic is true, insufficient capacity leaves the buffer unchanged.
Definition at line 201 of file Buffer.cc.
Referenced by ConsoleFile::inputLineDiscipline(), and Ps2Controller::irq().
Here is the caller graph for this function:
|
private |
Appends up to count values while m_Lock is held.
Definition at line 679 of file Buffer.cc.
References Buffer< T, allowShortOperation >::Segment::data, and Buffer< T, allowShortOperation >::Segment::size.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |