New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'does' is not threadsafe #6361
Comments
From @BenGoldberg1Here's an IRC snippet showing the problem: <BenGoldberg> m: await start { my $a = "strange"; $a does role Test { }; } xx 16 Using a Lock solves the problem, but there ought to be a better solution. <BenGoldberg> m: my $l = Lock.new; await start { my $a = "dubba"; role Test { }; $l.protect: { $a does Test }; } xx 16 |
From @jnthnOn Sun, 25 Jun 2017 23:14:00 -0700, ben-goldberg@hotmail.com wrote:
I think you wanted `but`. `does` is in-place, and you're therefore in-place mutating a string from the constant table in this case and that will have global effect on the program. Such things will likely at some point become an error. Note that if this was successful, it would be applying the role Test to the same thing 16 times. It's easy to remember which of the in-place mutation operators in Perl 6 are threadsafe, because none of them are (does, ++, --, the = meta-operator, and so forth). So, rejecting as it was never intended that concurrently mixing in to the same object without any kind of protection would work out, and the original code is probably confused and wanted to use `but` anyway. /jnthn |
The RT System itself - Status changed from 'new' to 'open' |
@jnthn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#131654 (status was 'rejected')
Searchable as RT131654$
The text was updated successfully, but these errors were encountered: