in reply to Re^2: Namespace weirdness with Parallel::ForkManager using 0 children
in thread SOLVED [ create_class_with_roles() ]: Moo[se] namespace weirdness with conditionally composed-in Roles
Adding the following line at the end of sub BUILD in “MyClass.pm” seems to fix the problem:
Role::Tiny->apply_roles_to_object($self, $module);
So my guess is: roles are, by default, class-based, rather than object-based, so that once a role has been added to a class, the definition of that class doesn’t change. But with multiple threads, the problem doesn’t arise as the class definition is re-created for each new thread.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Namespace weirdness with Parallel::ForkManager using 0 children
by 1nickt (Canon) on Mar 21, 2016 at 08:14 UTC |