File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ?if !parrot
2
+ my class NQPLock is repr(' ReentrantMutex' ) {
3
+ class ConditionVariable is repr(' ConditionVariable' ) {
4
+ method new () {
5
+ nqp ::die(" Cannot directly create a ConditionVariable; use the 'condition' method on a lock" );
6
+ }
7
+ method wait () { nqp ::condwait(self ) }
8
+ method signal () { nqp ::condsignalone(self ) }
9
+ method signal_all () { nqp ::condsignalall(self ) }
10
+ }
11
+
12
+ method new () { nqp ::create(self ) }
13
+
14
+ method lock () { nqp ::lock(self ) }
15
+
16
+ method unlock () { nqp ::unlock(self ) }
17
+
18
+ method protect ($ code ) {
19
+ nqp ::lock(self );
20
+ my $ res := $ code ();
21
+ nqp ::unlock(self );
22
+ CATCH { nqp ::unlock(self ); }
23
+ $ res
24
+ }
25
+
26
+ method condition () {
27
+ nqp ::getlockcondvar(self , ConditionVariable)
28
+ }
29
+ }
30
+ # ?endif
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ CORE_SETTING_SOURCES = \
18
18
src/core/IO.nqp \
19
19
src/core/Regex.nqp \
20
20
src/core/Hash.nqp \
21
+ src/core/NQPLock.nqp \
21
22
src/core/testing.nqp \
22
23
src/core/YOUAREHERE.nqp \
23
24
You can’t perform that action at this time.
0 commit comments