22#include "pedigree/kernel/Atomic.h"
23#include "pedigree/kernel/process/Event.h"
24#include "pedigree/kernel/process/Semaphore.h"
25#include "pedigree/kernel/process/Thread.h"
26#include "pedigree/kernel/utilities/BufferMonitors.h"
27#include "pedigree/kernel/utilities/Mailbox.h"
29namespace RingBufferWait = MailboxWait;
32 void changed(
bool becameReadable,
bool becameWritable) {
34 readableGeneration += 1;
37 writableGeneration += 1;
52template <
class T,
size_t preallocatedSize = 0>
53class EXPORTED_PUBLIC
RingBuffer :
public Mailbox<T, preallocatedSize, RingBufferNotifications> {
59 uint64_t readableGeneration()
const {
60 return this->m_Notifications.readableGeneration.value();
63 uint64_t writableGeneration()
const {
64 return this->m_Notifications.writableGeneration.value();
92 if (this->readsClosed()) {
102 return this->m_Notifications.monitors.add(pThread, pEvent);
115 if (this->readsClosed()) {
122 this->m_Notifications.monitors.add(pSemaphore);
133 this->m_Notifications.monitors.cull(pThread);
143 this->m_Notifications.monitors.cull(pSemaphore);
153 this->m_Notifications.monitors.cull(pEvent);
bool tryAcquireRegistration(SendLease ®istration)
bool monitor(Thread *pThread, Event *pEvent)
monitor - add a new Event to be fired when something happens
void cullMonitorTargets(Semaphore *pSemaphore)
Cull all monitor targets pointing to pSemaphore.
bool monitor(Semaphore *pSemaphore)
Add a Semaphore to be signaled when readiness changes or the ring closes.
void cullMonitorTargets(Event *pEvent)
Cull all monitor targets pointing to pEvent.
void cullMonitorTargets(Thread *pThread)
Cull all monitor targets pointing to pThread.
bool sendEvent(Event *pEvent)