Skip to content

Commit

Permalink
Fudge Thread & Monitor to be correctly exported
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 15, 2010
1 parent 38b3ab2 commit 5b8140e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Threads.pm6
@@ -1,7 +1,8 @@
module Threads;
my module Threads;

# Should be a role, since it can be applied to any class with minimal overhead
class Monitor is export {
# XXX STD doesn't want to do the export if the class is our
my class Monitor is export {
method enter() {
Q:CgOp {
(prog (rawscall System.Threading.Monitor.Enter:m,Void
Expand All @@ -18,7 +19,9 @@ class Monitor is export {
method lock($f) { self.enter; $f(); self.exit }
}

class Thread is export {
sub lock($m,$f) is export { $m.lock($f); }

my class Thread is export {
method new($func) {
Q:CgOp { (box Thread (rawsccall
Kernel.StartP6Thread:c,System.Threading.Thread (@ (l $func)))) }
Expand All @@ -33,3 +36,5 @@ class Thread is export {
Q:CgOp { (prog (rawscall System.Threading.Thread.Sleep:m,Void (cast Int32 (unbox Double (@ (l $t))))) (null Variable)) }
}
}

sub sleep($time) is export { Thread.sleep($time) }

0 comments on commit 5b8140e

Please sign in to comment.