Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created October 5, 2021 15:52
Show Gist options
  • Save dogbert17/20bd2f83e2c8082e57b3d23538bca6fa to your computer and use it in GitHub Desktop.
Save dogbert17/20bd2f83e2c8082e57b3d23538bca6fa to your computer and use it in GitHub Desktop.
Test for bug
my %objects;
my Lock $ol .= new;
class Bar {
submethod TWEAK (|) {
$ol.protect: {
my $obj-id = self.WHICH;
die "DUPLICATE FOUND: ", $obj-id if %objects{$obj-id};
%objects{$obj-id} = True;
say $obj-id;
}
}
submethod DESTROY {
$ol.protect: {
my $obj-id = self.WHICH;
say "DESTROY ", $obj-id;
%objects{$obj-id}:delete;
}
}
}
my @p;
for 1..100 {
for 1..100 {
Bar.new;
@p.push: start {
# Bar.new;
sleep .01;
}
}
}
await @p;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment