Skip to content

Commit

Permalink
[js] Disable locking code that serves no purpose
Browse files Browse the repository at this point in the history
It needs to be fixed on the js backend as it's causing exceptions
  • Loading branch information
pmurias committed Nov 8, 2017
1 parent ee213cb commit 95991af
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/Lock/Async.pm
Expand Up @@ -62,6 +62,7 @@ my class Lock::Async {
}

method lock(Lock::Async:D: --> Promise) {
#?if !js
loop {
my $holder :=$!holder;
if $holder.DEFINITE {
Expand All @@ -79,9 +80,14 @@ my class Lock::Async {
}
}
}
#?endif
#?if js
return KEPT-PROMISE;
#?endif
}

method unlock(Lock::Async:D: --> Nil) {
#?if !js
loop {
my $holder :=$!holder;
if $holder =:= SINGLE_HOLDER {
Expand Down Expand Up @@ -116,13 +122,16 @@ my class Lock::Async {
die X::Lock::Async::NotLocked.new;
}
}
#?endif
}

method protect(Lock::Async:D: &code) {
#?if !js
my int $acquired = 0;
$*AWAITER.await(self.lock());
$acquired = 1;
LEAVE self.unlock() if $acquired;
#?endif
code()
}

Expand Down

0 comments on commit 95991af

Please sign in to comment.