ADT
ast-experimental
Last change
on this file since ff443e5 was 9a9ca36, checked in by caparsons <caparson@…>, 3 years ago |
a little bit of mutex stmt header cleanup
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[5e4a830] | 1 | #pragma once
|
---|
| 2 |
|
---|
[1b97976c] | 3 | #include "bits/algorithm.hfa"
|
---|
[eb9c2dc] | 4 | #include "bits/defs.hfa"
|
---|
[1b97976c] | 5 |
|
---|
| 6 | //-----------------------------------------------------------------------------
|
---|
| 7 | // is_lock
|
---|
[dd3576b] | 8 | forall(L & | sized(L))
|
---|
| 9 | trait is_lock {
|
---|
[1b97976c] | 10 | // For acquiring a lock
|
---|
| 11 | void lock( L & );
|
---|
| 12 |
|
---|
| 13 | // For releasing a lock
|
---|
| 14 | void unlock( L & );
|
---|
| 15 | };
|
---|
| 16 |
|
---|
| 17 |
|
---|
[0d4f954] | 18 | struct __mutex_stmt_lock_guard {
|
---|
| 19 | void ** lockarr;
|
---|
| 20 | __lock_size_t count;
|
---|
| 21 | };
|
---|
[1b97976c] | 22 |
|
---|
[0d4f954] | 23 | static inline void ?{}( __mutex_stmt_lock_guard & this, void * lockarr [], __lock_size_t count ) {
|
---|
| 24 | this.lockarr = lockarr;
|
---|
| 25 | this.count = count;
|
---|
[1b97976c] | 26 |
|
---|
[0d4f954] | 27 | // Sort locks based on address
|
---|
| 28 | __libcfa_small_sort(this.lockarr, count);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | forall(L & | is_lock(L)) {
|
---|
[a8367eb] | 32 |
|
---|
[c1d8cde] | 33 | struct scoped_lock {
|
---|
| 34 | L * internal_lock;
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | static inline void ?{}( scoped_lock(L) & this, L & internal_lock ) {
|
---|
| 38 | this.internal_lock = &internal_lock;
|
---|
| 39 | lock(internal_lock);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | static inline void ^?{}( scoped_lock(L) & this ) with(this) {
|
---|
| 43 | unlock(*internal_lock);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[0d4f954] | 46 | static inline void * __get_mutexstmt_lock_ptr( L & this ) {
|
---|
[a8367eb] | 47 | return &this;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
[0d4f954] | 50 | static inline L __get_mutexstmt_lock_type( L & this );
|
---|
[a8367eb] | 51 |
|
---|
[0d4f954] | 52 | static inline L __get_mutexstmt_lock_type( L * this );
|
---|
[dd3576b] | 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.