ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 6cff9f3 was
6cff9f3,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Implementation of a priority queue for alarms
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | // -*- Mode: CFA -*- |
---|
2 | // |
---|
3 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
4 | // |
---|
5 | // The contents of this file are covered under the licence agreement in the |
---|
6 | // file "LICENCE" distributed with Cforall. |
---|
7 | // |
---|
8 | // alarm.h -- |
---|
9 | // |
---|
10 | // Author : Thierry Delisle |
---|
11 | // Created On : Fri Jun 2 11:31:25 2017 |
---|
12 | // Last Modified By : Thierry Delisle |
---|
13 | // Last Modified On : -- |
---|
14 | // Update Count : 0 |
---|
15 | // |
---|
16 | |
---|
17 | #ifndef ALARM_H |
---|
18 | #define ALARM_H |
---|
19 | |
---|
20 | #include "assert" |
---|
21 | |
---|
22 | typedef unsigned long int cfa_time_t; |
---|
23 | |
---|
24 | struct thread_desc; |
---|
25 | struct processor; |
---|
26 | |
---|
27 | struct alarm_node_t { |
---|
28 | cfa_time_t alarm; // time when alarm goes off |
---|
29 | cfa_time_t period; // if > 0 => period of alarm |
---|
30 | alarm_node_t * next; // intrusive link list field |
---|
31 | |
---|
32 | union { |
---|
33 | thread_desc * thrd; // thrd who created event |
---|
34 | processor * proc; // proc who created event |
---|
35 | }; |
---|
36 | }; |
---|
37 | |
---|
38 | typedef alarm_node_t ** __alarm_it_t; |
---|
39 | |
---|
40 | void ?{}( alarm_node_t * this, thread_desc * thrd, cfa_time_t alarm, cfa_time_t period = 0 ); |
---|
41 | void ?{}( alarm_node_t * this, processor * proc, cfa_time_t alarm, cfa_time_t period = 0 ); |
---|
42 | |
---|
43 | struct alarm_list_t { |
---|
44 | alarm_node_t * head; |
---|
45 | __alarm_it_t tail; |
---|
46 | }; |
---|
47 | |
---|
48 | static inline void ?{}( alarm_list_t * this ) { |
---|
49 | this->head = 0; |
---|
50 | this->tail = &this->head; |
---|
51 | } |
---|
52 | |
---|
53 | void insert( alarm_list_t * this, alarm_node_t * n ); |
---|
54 | alarm_node_t * pop( alarm_list_t * this ); |
---|
55 | |
---|
56 | #endif |
---|
57 | |
---|
58 | // Local Variables: // |
---|
59 | // mode: CFA // |
---|
60 | // tab-width: 6 // |
---|
61 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.