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

Commit bfd08910 authored by Sharvil Nanavati's avatar Sharvil Nanavati Committed by Sharvil Nanavati
Browse files

Expose enqueue/dequeue file descriptors for fixed_queue.

These file descriptors can be used with a reactor to perform
non-blocking enqueue/dequeue operations.

Change-Id: If75730f9093e8d20a789a7bd2bde92e019922e5a
parent 56bab973
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -56,3 +56,17 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data);
// Otherwise, the next element in the queue is returned. |queue| may not be
// NULL.
void *fixed_queue_try_dequeue(fixed_queue_t *queue);

// This function returns a valid file descriptor. Callers may perform one
// operation on the fd: select(2). If |select| indicates that the file
// descriptor is readable, the caller may call |fixed_queue_enqueue| without
// blocking. The caller must not close the returned file descriptor. |queue|
// may not be NULL.
int fixed_queue_get_enqueue_fd(const fixed_queue_t *queue);

// This function returns a valid file descriptor. Callers may perform one
// operation on the fd: select(2). If |select| indicates that the file
// descriptor is readable, the caller may call |fixed_queue_dequeue| without
// blocking. The caller must not close the returned file descriptor. |queue|
// may not be NULL.
int fixed_queue_get_dequeue_fd(const fixed_queue_t *queue);
+10 −0
Original line number Diff line number Diff line
@@ -139,3 +139,13 @@ void *fixed_queue_try_dequeue(fixed_queue_t *queue) {

  return ret;
}

int fixed_queue_get_dequeue_fd(const fixed_queue_t *queue) {
  assert(queue != NULL);
  return semaphore_get_fd(queue->dequeue_sem);
}

int fixed_queue_get_enqueue_fd(const fixed_queue_t *queue) {
  assert(queue != NULL);
  return semaphore_get_fd(queue->enqueue_sem);
}