Limit closure copying to just copied classes
Closed this issue · 3 comments
dktapps commented
Currently, all closures are copied even when using PTHREADS_INHERIT_NONE, including ones not declared in Threaded classes. This is a performance drag and a waste of memory.
dktapps commented
In addition, copying all closures may result in the unintended copying of other classes, even when PTHREADS_INHERIT_NONE was used.
dktapps commented
Further to this, it seems that pthreads does not copy or fix the scopes of said closures, meaning that faults may occur when instantiating or using them.
dktapps commented
Investigation with a debugger suggests that the scopes of the source closures are NULL
, so it's not possible to detect which class owned them short of going through each opcode trying to find them.