Closures are weirdly broken in pthreads in various ways.
The following restrictions must be imposed:
[x] No use-by-reference. This currently silently breaks - the reference is turned into a regular value.
[ ] No complex NTS uses. Currently, NTS types are silently removed, leading to code crashing when using used variables. This means that closure uses must be limited to the following:
Scalar
NULL
Threaded objects
Other valid closures
Sockets
[x] No static variables. Static variables are impossible to make sane, since they can be altered after the closure is assigned to the Threaded object, making it impossible to verify their thread-safety. Therefore, local static variables must be prohibited entirely.
[x] No NTS $this. Closure scope is currently silently obliterated when dereferenced on another thread, leading to crashes when a closure attempts to use $this.
[x] Closures with a thread-safe $this (e.g. a ThreadedBase) must have their $this restored.
Closures are weirdly broken in pthreads in various ways.
The following restrictions must be imposed:
use
d variables. This means that closure uses must be limited to the following:$this
. Closure scope is currently silently obliterated when dereferenced on another thread, leading to crashes when a closure attempts to use$this
.$this
(e.g. a ThreadedBase) must have their$this
restored.