Remove pointers from Genode::Fifo interface

Replace methods of Genode::Fifo returning pointers with methods which
call lambdas with references.

Ref #3135
This commit is contained in:
Emery Hemingway
2019-01-29 19:29:03 +01:00
committed by Norman Feske
parent 328c1ad96e
commit 38ab456c78
26 changed files with 367 additions and 380 deletions

View File

@@ -108,10 +108,12 @@ class Timed_semaphore : public Semaphore
* Iterate through the queue and find the thread,
* with the corresponding timeout.
*/
Element *first = Semaphore::_queue.dequeue();
Element *first = nullptr;
Semaphore::_queue.dequeue([&first] (Element &e) {
first = &e; });
Element *e = first;
while (true) {
while (e) {
/*
* Wakeup the thread.
@@ -124,8 +126,10 @@ class Timed_semaphore : public Semaphore
/*
* Noninvolved threads are enqueued again.
*/
Semaphore::_queue.enqueue(e);
e = Semaphore::_queue.dequeue();
Semaphore::_queue.enqueue(*e);
e = nullptr;
Semaphore::_queue.dequeue([&e] (Element &next) {
e = &next; });
/*
* Maybe, the alarm was triggered just after the corresponding
@@ -210,7 +214,7 @@ class Timed_semaphore : public Semaphore
* in the wait queue.
*/
Element queue_element;
Semaphore::_queue.enqueue(&queue_element);
Semaphore::_queue.enqueue(queue_element);
Semaphore::_meta_lock.unlock();
/* Create the timeout */

View File

@@ -78,7 +78,7 @@ struct rumpuser_mtx
if (try_enter)
return false;
fifo.enqueue(&applicant);
fifo.enqueue(applicant);
}
applicant.block();
}
@@ -99,8 +99,8 @@ struct rumpuser_mtx
owner = nullptr;
}
if (Applicant *applicant = fifo.dequeue())
applicant->wake_up();
fifo.dequeue([] (Applicant &applicant) {
applicant.wake_up(); });
}
};