ADTast-experimental
Last change
on this file since 0da7181 was
9a9ca36,
checked in by caparsons <caparson@…>, 19 months ago
|
a little bit of mutex stmt header cleanup
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | #include "bits/algorithm.hfa" |
---|
4 | #include "bits/defs.hfa" |
---|
5 | |
---|
6 | //----------------------------------------------------------------------------- |
---|
7 | // is_lock |
---|
8 | forall(L & | sized(L)) |
---|
9 | trait is_lock { |
---|
10 | // For acquiring a lock |
---|
11 | void lock( L & ); |
---|
12 | |
---|
13 | // For releasing a lock |
---|
14 | void unlock( L & ); |
---|
15 | }; |
---|
16 | |
---|
17 | |
---|
18 | struct __mutex_stmt_lock_guard { |
---|
19 | void ** lockarr; |
---|
20 | __lock_size_t count; |
---|
21 | }; |
---|
22 | |
---|
23 | static inline void ?{}( __mutex_stmt_lock_guard & this, void * lockarr [], __lock_size_t count ) { |
---|
24 | this.lockarr = lockarr; |
---|
25 | this.count = count; |
---|
26 | |
---|
27 | // Sort locks based on address |
---|
28 | __libcfa_small_sort(this.lockarr, count); |
---|
29 | } |
---|
30 | |
---|
31 | forall(L & | is_lock(L)) { |
---|
32 | |
---|
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 | |
---|
46 | static inline void * __get_mutexstmt_lock_ptr( L & this ) { |
---|
47 | return &this; |
---|
48 | } |
---|
49 | |
---|
50 | static inline L __get_mutexstmt_lock_type( L & this ); |
---|
51 | |
---|
52 | static inline L __get_mutexstmt_lock_type( L * this ); |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.