Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31e43b66 authored by Ying Hsu's avatar Ying Hsu Committed by Automerger Merge Worker
Browse files

Merge "Add comments for BidiQueue, BidiQueueEnd, and Queue" into main am: 1d4cf256

parents fe93c809 1d4cf256
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@
namespace bluetooth {
namespace common {

//
// Interface for one context to send and receive data over
// a pair of queues (|BidiQueue|).
//
template <typename TENQUEUE, typename TDEQUEUE>
class BidiQueueEnd : public ::bluetooth::os::IQueueEnqueue<TENQUEUE>,
                     public ::bluetooth::os::IQueueDequeue<TDEQUEUE> {
@@ -54,6 +58,22 @@ private:
  ::bluetooth::os::IQueueDequeue<TDEQUEUE>* rx_;
};

//
// Interface managing a pair of queues shared between two contexts
// (typically layers of the stack).
//
// The up queue can be used for data to indicate up to bluetooth host and
// the down queue can be used for data to sent to bluetooth controller.
// Each context uses its |BidiQueueEnd| to manage their data operations:
//
// The up end:
// - Receives data indicated from the down end.
// - Sends data to the down end.
//
// The down end:
// - Receives data sent from the up end.
// - Indicates data to the up end.
//
template <typename TUP, typename TDOWN>
class BidiQueue {
public:
+14 −0
Original line number Diff line number Diff line
@@ -53,6 +53,20 @@ public:
  virtual std::unique_ptr<T> TryDequeue() = 0;
};

//
// An interface facilitating flow-controlled and non-blocking queue operations.
//
// This Queue uses separate semaphores and callbacks for enqueue end (producer)
// and dequeue end (consumer) to manage data flow efficiently:
//
// Enqueue end (producer):
// - Registers an EnqueueCallback when producer has data to send.
// - Unregisters the EnqueueCallback when no data is available.
//
// Dequeue end (consumer):
// - Registers a DequeueCallback when consumer is ready to process data.
// - Unregisters the DequeueCallback when no longer ready.
//
template <typename T>
class Queue : public IQueueEnqueue<T>, public IQueueDequeue<T> {
public: