1. my class Semaphore is repr('Semaphore') {
  2. method new(int $permits) {
  3. nqp::box_i($permits, Semaphore);
  4. }
  5. method acquire() {
  6. nqp::semacquire(self);
  7. }
  8. method try_acquire(--> Bool:D) {
  9. nqp::p6bool(nqp::semtryacquire(self))
  10. }
  11. method release() {
  12. nqp::semrelease(self);
  13. }
  14. }