/
Actors.pm6
35 lines (29 loc) · 884 Bytes
/
Actors.pm6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
role Actor {
has Lock::Async $!orderer .= new;
method !post($method, $capture) {
$!orderer.lock.then({
LEAVE $!orderer.unlock;
$method(self, |$capture)
});
}
}
class MetamodelX::ActorHOW is Metamodel::ClassHOW {
my %bypass = :new, :bless, :BUILDALL, :BUILD, 'dispatch:<!>' => True;
method find_method(Mu \obj, $name, |) {
my $method = callsame;
my $post = self.find_private_method(obj, 'post');
%bypass{$name} || !$method
?? $method
!! -> \obj, |capture { $post(obj, $method, capture); }
}
method compose(Mu \type) {
self.add_role(type, Actor);
self.Metamodel::ClassHOW::compose(type);
}
method publish_method_cache(|) { }
}
my package EXPORTHOW {
package DECLARE {
constant actor = MetamodelX::ActorHOW;
}
}