Skip to content

Releases: pmmp/ext-pmmpthread

6.0.5

20 Jul 14:34
023bba8
Compare
Choose a tag to compare

Changes since 6.0.4

  • Fixed objects not being able to be passed to another thread once their creator thread no longer references them.
  • Fixed crash when accessing nonexistent multi-dimensional offsets of ThreadSafeArray.

6.0.4

21 Jun 11:20
b309feb
Compare
Choose a tag to compare

Changes since 6.0.3

  • Fixed Runnable::isTerminated() returning false when the Runnable crashed on a thread with an exception handler registered (#123).

6.0.3

21 Jun 11:17
f41d6b6
Compare
Choose a tag to compare

Changes since 6.0.2

  • Fixed uninitialized variable in pmmpthread_has_property handler

6.0.2

06 Jun 14:58
e62c3ef
Compare
Choose a tag to compare

Changes since 6.0.1

  • Fixed &$undefined variables in closure use()s causing segfaults in copied closures - #112

6.0.1

03 Jun 18:30
e285bf8
Compare
Choose a tag to compare

Changes since 6.0.0

  • Fixed mishandling of permanent strings in ThreadSafe and ThreadSafeArray (reads returned a stale cached version of strings after modification by another thread) - #119

6.0.0

22 May 21:29
12cd4af
Compare
Choose a tag to compare

This major version renames the extension from pthreads to pmmpthread, refactors and renames some classes, and generally cleans up some magic stuff leftover from v5.

The overall system architecture is mostly the same as v5. This version mostly differs in terms of the API it presents.

If you're upgrading from v4, please see docs/UPGRADING_4.x_to_6.0.md.

Changes since 5.x

General

  • PHP 8.1 is now required. 8.0 was dropped due to various inconsistencies and bugs.
  • Extension has been renamed to pmmpthread.
    • This change allows the extension to be potentially submitted to PECL as well as submitting stubs for jetbrains/phpstorm-stubs.
    • In theory, it should also be able to coexist with previous pthreads versions, but I don't recommend trying to load both at the same time.

API changes

  • All classes have been moved to the pmmp\thread namespace.
  • The following classes have been renamed:
    • ThreadedBase -> pmmp\thread\ThreadSafe
    • ThreadedArray -> pmmp\thread\ThreadSafeArray
    • ThreadedRunnable -> pmmp\thread\Runnable
    • ThreadedConnectionException -> pmmp\thread\ConnectionException
    • Thread -> pmmp\thread\Thread
    • Worker -> pmmp\thread\Worker
  • PTHREADS_INHERIT_* constants have been moved to Thread::INHERIT_* class constants.
  • Thread::start() now requires the $options parameter to be specified. INHERIT_NONE should be preferred for large applications, while INHERIT_ALL will likely be necessary for small test scripts.
  • Added Thread::getSharedGlobals() : ThreadSafeArray, which returns a ThreadSafeArray automatically available to all threads.
  • Resources are no longer considered thread-safe values, and are no longer accepted as properties of any ThreadSafe object.
  • Removed magic worker field declared on task classes submitted to Workers. This can be done using Thread::getCurrentThread() instead.
  • Class static property default values are now always used by inherited classes. This was previously inconsistent when OPcache was used, as property defaults would inconsistently be mixed with property values copied from the parent thread at the time of thread creation.
  • pmmp\thread\NonThreadSafeValueError is now thrown when attempting to assign any non-thread-safe value to a property or offset of ThreadSafe.

Fixes

  • Fixed memory leak when connecting Runnable objects for execution.
  • ThreadSafeArray (ThreadedArray) no longer supports property operations (these were previously proxied to array offset write operations by mistake). Now, an error is generated instead.
  • Workers no longer accept tasks after shutdown.
  • Workers now terminate themselves if a task encounters a fatal error. Previously, a task could cause a fatal error (e.g. by leaking memory), and the worker would stay alive in a broken state, with no way for the parent thread to know there was a problem.
  • Workers no longer accept tasks if an error occurred during execution.
  • Fixed some auto globals being armed multiple times, causing performance losses during thread start.

6.0.0-beta1

19 May 22:10
0294ccf
Compare
Choose a tag to compare
6.0.0-beta1 Pre-release
Pre-release

This major version renames the extension from pthreads to pmmpthread, refactors and renames some classes, and generally cleans up some magic stuff leftover from v5.

The overall system architecture is mostly the same as v5. This version mostly differs in terms of the API it presents.

Changes since 5.x

General

  • PHP 8.1 is now required. 8.0 was dropped due to various inconsistencies and bugs.
  • Extension has been renamed to pmmpthread.
    • This change allows the extension to be potentially submitted to PECL as well as submitting stubs for jetbrains/phpstorm-stubs.
    • In theory, it should also be able to coexist with previous pthreads versions, but I don't recommend trying to load both at the same time.

API changes

  • All classes have been moved to the pmmp\thread namespace.
  • The following classes have been renamed:
    • ThreadedBase -> pmmp\thread\ThreadSafe
    • ThreadedArray -> pmmp\thread\ThreadSafeArray
    • ThreadedRunnable -> pmmp\thread\Runnable
    • ThreadedConnectionException -> pmmp\thread\ConnectionException
    • Thread -> pmmp\thread\Thread
    • Worker -> pmmp\thread\Worker
  • PTHREADS_INHERIT_* constants have been moved to Thread::INHERIT_* class constants.
  • Thread::start() now requires the $options parameter to be specified. INHERIT_NONE should be preferred for large applications, while INHERIT_ALL will likely be necessary for small test scripts.
  • Added Thread::getSharedGlobals() : ThreadSafeArray, which returns a ThreadSafeArray automatically available to all threads.
  • Resources are no longer considered thread-safe values, and are no longer accepted as properties of any ThreadSafe object.
  • Removed magic worker field declared on task classes submitted to Workers. This can be done using Thread::getCurrentThread() instead.
  • Class static property default values are now always used by inherited classes. This was previously inconsistent when OPcache was used, as property defaults would inconsistently be mixed with property values copied from the parent thread at the time of thread creation.

Fixes

  • Fixed memory leak when connecting Runnable objects for execution.
  • ThreadSafeArray (ThreadedArray) no longer supports property operations (these were previously proxied to array offset write operations by mistake). Now, an error is generated instead.
  • Workers no longer accept tasks after shutdown.
  • Workers now terminate themselves if a task encounters a fatal error. Previously, a task could cause a fatal error (e.g. by leaking memory), and the worker would stay alive in a broken state, with no way for the parent thread to know there was a problem.
  • Workers no longer accept tasks if an error occurred during execution.
  • Fixed some auto globals being armed multiple times, causing performance losses during thread start.

5.3.1

24 Mar 16:55
a85d38b
Compare
Choose a tag to compare
  • Fixed edge case with nested thread-safe objects that could lead to avoidable ThreadedConnectionExceptions being thrown.
  • Improved performance of dereferencing thread-safe objects from another thread by avoiding useless internal allocations. This reduces overhead for things like Worker.

5.3.0

13 Mar 19:34
bd873e8
Compare
Choose a tag to compare

Changes since 5.2.x

This release mainly focuses on improving closure behaviour, and imposing clear restrictions.

Behaviour changes

  • Thread-safe objects can no longer be serialized. Previously, they would serialize to a pointer, which was useless aside from the old serialize hacks used by pthreads v4 and earlier.
  • Closures with a non-thread-safe $this can no longer be assigned to thread-safe objects. Previously, $this would be silently removed.
    • Tip: Use static function or static fn to prevent $this being bound to closures when you don't need it.
  • Closures with a thread-safe $this will now have $this restored when copying a closure out onto a new thread (as you would expect). Previously, $this was never copied.
  • Closures with static variables (e.g. static $var;) can no longer be assigned to thread-safe objects. This is because their values can change in ways that pthreads can't track, making it impossible to make their behaviour predictable.
    • To persist closure state in a thread-safe manner, consider use()ing a thread-safe object into the closure instead of using static variables.
  • Closures with use-by-reference can no longer be assigned to thread-safe objects. This is because references can't be updated from a different thread, making it impossible to give them intuitive behaviour.

Please note that the behaviour of closures may still change as the desired behaviour is finalized before the 6.0.0 release.

Fixes

  • Repeatedly passing the same closure from one thread to another no longer causes a memory leak on the receiving thread, thanks to improvements in closure definition vs instance handling.
  • Fake closures (first-class callables, or closures created using Closure::fromCallable()) now share the static variables of the original function in 8.1 and up when copied between threads, as a non-copied closure would.
  • ThreadedArray::merge() now throws better exceptions when attempting to merge non-thread-safe elements.
  • Fixed Unsupported data type callable when attempting to use ThreadedArray::merge() with an object containing unmodified typed properties (improper IS_INDIRECT handling).
  • Fixed bogus "access before initialization" errors being generated when attempting to assign a reference to a thread-safe object.

5.2.4

07 Feb 13:56
b7e51ec
Compare
Choose a tag to compare

Changes since 5.2.3

  • Fixed segfault when synchronizing an object containing a thread-safe object destroyed by another thread.
  • Fixed segfault on thread shutdown when the owner of a resource unsets it from a thread-safe object property.
  • Reduced allocations in thread-safe property storage, which should improve performance.
  • Remove useless property table rebuild when writing a thread-safe object to a property of another thread-safe object.
  • Fixed assert failure when using ReflectionObject->getProperties() on a ThreadedArray which was only modified using []=.
  • Cleaned up code in some areas, fixing a bunch of compiler warnings.
  • Added missing get_gc handler for iterators.