ADTast-experimental
Last change
on this file since 5f6b2c2 was
0d4f954,
checked in by caparsons <caparson@…>, 2 years ago
|
changed concurrency library to work with new mutexstmt changes
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "bits/algorithm.hfa" |
---|
2 | #include "bits/defs.hfa" |
---|
3 | |
---|
4 | //----------------------------------------------------------------------------- |
---|
5 | // is_lock |
---|
6 | trait is_lock(L & | sized(L)) { |
---|
7 | // For acquiring a lock |
---|
8 | void lock( L & ); |
---|
9 | |
---|
10 | // For releasing a lock |
---|
11 | void unlock( L & ); |
---|
12 | }; |
---|
13 | |
---|
14 | |
---|
15 | struct __mutex_stmt_lock_guard { |
---|
16 | void ** lockarr; |
---|
17 | __lock_size_t count; |
---|
18 | }; |
---|
19 | |
---|
20 | static inline void ?{}( __mutex_stmt_lock_guard & this, void * lockarr [], __lock_size_t count ) { |
---|
21 | this.lockarr = lockarr; |
---|
22 | this.count = count; |
---|
23 | |
---|
24 | // Sort locks based on address |
---|
25 | __libcfa_small_sort(this.lockarr, count); |
---|
26 | |
---|
27 | // acquire locks in order |
---|
28 | // for ( size_t i = 0; i < count; i++ ) { |
---|
29 | // lock(*this.lockarr[i]); |
---|
30 | // } |
---|
31 | } |
---|
32 | |
---|
33 | static inline void ^?{}( __mutex_stmt_lock_guard & this ) with(this) { |
---|
34 | // for ( size_t i = count; i > 0; i-- ) { |
---|
35 | // unlock(*lockarr[i - 1]); |
---|
36 | // } |
---|
37 | } |
---|
38 | |
---|
39 | forall(L & | is_lock(L)) { |
---|
40 | |
---|
41 | struct scoped_lock { |
---|
42 | L * internal_lock; |
---|
43 | }; |
---|
44 | |
---|
45 | static inline void ?{}( scoped_lock(L) & this, L & internal_lock ) { |
---|
46 | this.internal_lock = &internal_lock; |
---|
47 | lock(internal_lock); |
---|
48 | } |
---|
49 | |
---|
50 | static inline void ^?{}( scoped_lock(L) & this ) with(this) { |
---|
51 | unlock(*internal_lock); |
---|
52 | } |
---|
53 | |
---|
54 | static inline void * __get_mutexstmt_lock_ptr( L & this ) { |
---|
55 | return &this; |
---|
56 | } |
---|
57 | |
---|
58 | static inline L __get_mutexstmt_lock_type( L & this ); |
---|
59 | |
---|
60 | static inline L __get_mutexstmt_lock_type( L * this ); |
---|
61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.