Skip to content

Commit

Permalink
Add cas operation on integers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Aug 15, 2017
1 parent 6eb8f7e commit 413b533
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/Atomic.pm
Expand Up @@ -45,6 +45,18 @@ multi sub cas($target is rw, $expected, $value) {
nqp::cas($target, $expected, $value)
}

multi sub cas(atomicint $target is rw, int $expected, int $value) {
nqp::cas_i($target, $expected, $value)
}

multi sub cas(atomicint $target is rw, Int $expected, Int $value) {
nqp::cas_i($target, $expected, $value)
}

multi sub cas(atomicint $target is rw, $expected, $value) {
nqp::cas_i($target, $expected.Int, $value.Int)
}

multi sub cas($target is rw, &code) {
my $current := nqp::atomicload($target);
loop {
Expand Down

0 comments on commit 413b533

Please sign in to comment.