view src/core.c/Semaphore.pm6 @ 0:c341f82e7ad7 default tip

Rakudo branch in cr.ie.u-ryukyu.ac.jp
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 26 Dec 2019 16:50:27 +0900
parents
children
line wrap: on
line source

my class Semaphore is repr('Semaphore') {
    method new(int $permits) {
        nqp::box_i($permits, Semaphore);
    }
    method acquire() {
        nqp::semacquire(self);
    }
    method try_acquire(--> Bool:D) {
        nqp::hllbool(nqp::semtryacquire(self))
    }
    method release() {
        nqp::semrelease(self);
    }
}

# vim: ft=perl6 expandtab sw=4