The Pedigree Project 0.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EventFd Class Referencefinal

#include <eventfd-syscalls.h>

+ Inheritance diagram for EventFd:
+ Collaboration diagram for EventFd:

Public Member Functions

 EventFd (uint64_t initialValue, bool semaphoreMode)
 
int readValue (uint64_t &value, bool canBlock)
 
int writeValue (uint64_t value, bool canBlock)
 
ReadyMask queryReady ()
 
ReadinessGenerations readinessGenerations () override
 
uint64_t writeGeneration () const
 
MUST_USE_RESULT bool addDescriptorOwner ()
 
void removeDescriptorOwner ()
 
- Public Member Functions inherited from ReadinessSource
MUST_USE_RESULT bool subscribeReadiness (ReadyMask interest, const SharedPointer< ReadinessObserver > &observer, ReadinessSubscription &subscription)
 

Private Member Functions

 EventFd (const EventFd &)=delete
 
EventFdoperator= (const EventFd &)=delete
 

Private Attributes

Mutex m_Lock
 
ConditionVariable m_Readers
 
ConditionVariable m_Writers
 
uint64_t m_Counter
 
Atomic< uint64_t > m_WriteGeneration
 
ReadinessGenerations m_Generations
 
size_t m_DescriptorOwners
 
bool m_SemaphoreMode
 
bool m_DescriptorAdmissionOpen
 

Additional Inherited Members

- Protected Member Functions inherited from ReadinessSource
void notifyReadiness (ReadyMask mask)
 
void closeReadiness (ReadyMask mask=ReadyInvalid|ReadyHangup)
 

Detailed Description

A Linux eventfd counter shared by every alias of one open description.

Definition at line 26 of file eventfd-syscalls.h.

Constructor & Destructor Documentation

◆ EventFd()

EventFd::EventFd ( uint64_t  initialValue,
bool  semaphoreMode 
)

Definition at line 32 of file eventfd-syscalls.cc.

◆ ~EventFd()

EventFd::~EventFd ( )
override

Definition at line 44 of file eventfd-syscalls.cc.

Member Function Documentation

◆ addDescriptorOwner()

bool EventFd::addDescriptorOwner ( )

Track descriptor-table aliases independently of in-flight syscall pins.

Definition at line 144 of file eventfd-syscalls.cc.

◆ queryReady()

ReadyMask EventFd::queryReady ( )

Return the current poll/epoll level.

Definition at line 123 of file eventfd-syscalls.cc.

◆ readinessGenerations()

ReadinessGenerations EventFd::readinessGenerations ( )
overridevirtual

Return source-serialized rising-edge sequences where available.

A source increments the corresponding sequence while holding the same lock which changes its readiness predicate. Consumers can then recover a drain/refill transition even if the two callback deliveries are reordered.

Reimplemented from ReadinessSource.

Definition at line 135 of file eventfd-syscalls.cc.

◆ readValue()

int EventFd::readValue ( uint64_t &  value,
bool  canBlock 
)

Read one eventfd value, blocking while the counter is zero if allowed.

Definition at line 49 of file eventfd-syscalls.cc.

References Semaphore::acquire(), ConditionVariable::broadcast(), ConditionVariable::mutexAcquired(), ReadinessSource::notifyReadiness(), Semaphore::release(), and ConditionVariable::wait().

◆ removeDescriptorOwner()

void EventFd::removeDescriptorOwner ( )

Definition at line 153 of file eventfd-syscalls.cc.

◆ writeGeneration()

uint64_t EventFd::writeGeneration ( ) const

Monotonically identifies every successful producer write for EPOLLET.

Definition at line 140 of file eventfd-syscalls.cc.

◆ writeValue()

int EventFd::writeValue ( uint64_t  value,
bool  canBlock 
)

Add one eventfd value, blocking while it would overflow if allowed.

Definition at line 86 of file eventfd-syscalls.cc.

References Semaphore::acquire(), ConditionVariable::broadcast(), ConditionVariable::mutexAcquired(), ReadinessSource::notifyReadiness(), Semaphore::release(), and ConditionVariable::wait().

Member Data Documentation

◆ m_Counter

uint64_t EventFd::m_Counter
private

Definition at line 56 of file eventfd-syscalls.h.

◆ m_DescriptorAdmissionOpen

bool EventFd::m_DescriptorAdmissionOpen
private

Definition at line 61 of file eventfd-syscalls.h.

◆ m_DescriptorOwners

size_t EventFd::m_DescriptorOwners
private

Definition at line 59 of file eventfd-syscalls.h.

◆ m_Generations

ReadinessGenerations EventFd::m_Generations
private

Definition at line 58 of file eventfd-syscalls.h.

◆ m_Lock

Mutex EventFd::m_Lock
private

Definition at line 53 of file eventfd-syscalls.h.

◆ m_Readers

ConditionVariable EventFd::m_Readers
private

Definition at line 54 of file eventfd-syscalls.h.

◆ m_SemaphoreMode

bool EventFd::m_SemaphoreMode
private

Definition at line 60 of file eventfd-syscalls.h.

◆ m_WriteGeneration

Atomic<uint64_t> EventFd::m_WriteGeneration
private

Definition at line 57 of file eventfd-syscalls.h.

◆ m_Writers

ConditionVariable EventFd::m_Writers
private

Definition at line 55 of file eventfd-syscalls.h.


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