-
Notifications
You must be signed in to change notification settings - Fork 57
/
k-waitstruct.hh
47 lines (38 loc) · 1.16 KB
/
k-waitstruct.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef CHICKADEE_K_WAITSTRUCT_HH
#define CHICKADEE_K_WAITSTRUCT_HH
#include "k-list.hh"
struct proc;
struct wait_queue;
struct spinlock;
struct irqstate;
struct spinlock_guard;
// k-waitstruct.hh
// Includes the struct definitions for `waiter` and `wait_queue`.
// The inline functions declared here are defined in `k-wait.hh`.
struct waiter {
proc* p_ = nullptr;
wait_queue* wq_;
list_links links_;
explicit inline waiter();
inline ~waiter();
NO_COPY_OR_ASSIGN(waiter);
inline void prepare(wait_queue& wq);
inline void maybe_block();
inline void clear();
inline void wake();
template <typename F>
inline void block_until(wait_queue& wq, F predicate);
template <typename F>
inline void block_until(wait_queue& wq, F predicate,
spinlock& lock, irqstate& irqs);
template <typename F>
inline void block_until(wait_queue& wq, F predicate,
spinlock_guard& guard);
};
struct wait_queue {
list<waiter, &waiter::links_> q_;
mutable spinlock lock_;
// you might want to provide some convenience methods here
inline void wake_all();
};
#endif