-
Notifications
You must be signed in to change notification settings - Fork 0
/
k-waitstruct.hh
56 lines (43 loc) · 1.38 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
48
49
50
51
52
53
54
55
56
#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 block();
inline void clear();
inline void wake();
inline void block_until_woken(wait_queue& wq, spinlock_guard& guard);
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();
inline void wake_all(spinlock_guard& guard);
inline void wake_one();
inline void wake_one(spinlock_guard& guard);
inline void wake_n(size_t n);
};
#endif