Releases: pmmp/ext-pmmpthread
5.0.1
5.0.0
This is a major release, featuring an API revamp, removal of various magic behaviours, and generally just making the API a bit less unpleasant to use.
The overall system architecture remains the same, so migrating from previous versions of pthreads shouldn't be too arduous.
Changes since 4.x
Behaviour
- Removed implicit
array
toVolatile
coercion. - Non-thread-safe values (objects, resources) are no longer automatically serialized when assigned to thread-safe objects. This magical behaviour produced bogus expectations. The onus of serializing is now on user code.
- Fixed private property shadowing when a thread-safe class extends another thread-safe class. Previously, private properties with the same name in different classes would overwrite each other.
- Property types are now verified on write for defined properties.
API
- Removed
Threaded
. The functionality ofThreaded
is now split between several classes:ThreadedBase
(abstract
) is a basic thread-safe object (wait()
,notify()
,notifyOne()
andsynchronized()
). In most cases,extends Threaded
should be directly replaced withextends ThreadedBase
.ThreadedArray
(final
) extendsThreadedBase
and offers array-like behaviour (shift()
,pop()
,merge()
,chunk()
,count()
,fromArray()
)ThreadedRunnable
(abstract
) extendsThreadedBase
(run()
,isRunning()
andisTerminated()
)Thread
now extendsThreadedRunnable
Thread
is nowabstract
.- Removed
ThreadedSocket
. Since PHP 8.0 and pthreads 4.0.0, native\Socket
objects can be shared between threads safely, so this class is no longer useful (it also significantly increased the maintenance burden of pthreads) - Removed
Volatile
. AllThreadedBase
descendents now support mutable operations involving otherThreadedBase
objects without performance impact, soVolatile
is now redundant. - Removed
Collectable
. This interface has been pointless for a while. - Manual refcounting APIs
addRef()
,delRef()
,getRefCount()
are removed. - Removed
Threaded::extend()
. This function made no sense and also violated class immutability when OPcache was used. ArrayAccess
is now able to be implemented byThreadedBase
objects. Previously, this did not work onThreaded
descendents.
Internals
- All thread-safe objects now support full mutability operations as in pthreads v2, but without the performance impact previously associated with
Volatile
. This is facilitated by a modification counter on the shared thread-safe object storage, allowing a low-cost way to check if syncing is necessary. - Improved performance and memory usage of thread-safe objects by reducing indirections, direct use of zval where appropriate, reduced copying, and more.
- Modernized parameter parsing using fast ZPP, which improves performance when calling any methods.
- All methods now have full parameter and return type info.
- Thread-safe local property tables are now only built when they are needed to be accessed, which improves performance and reduces memory usage.
4.2.0
4.1.4
Changes since 4.1.3
- Fixed crashes in
Threaded::chunk()
,Threaded::shift()
andThreaded::pop()
(caused by improper memory leak fix in e3e05d9). - Fixed crashes in
foreach
onThreaded
objects (caused by improper memory leak fix in e3e05d9). - Fixed segfaults, assert failures and other crashes in
Threaded::chunk()
andvar_dump(Threaded)
due toThreaded
shared keys being used in non-shared arrays (refcount races).
4.1.3
4.1.2
Changes since 4.1.1
- Fixed CE_CACHE leaking onto other threads. This issue affected only non-OPcache users. Unfortunately, the fix means that memory usage without OPcache is now higher than before, since request-local interned strings can no longer be safely shared.
4.1.1
4.1.0
Changes since 4.0.0
- Preliminary PHP 8.1 support (inheriting object constants is not currently supported, although enums work correctly - anything autoloaded will however work fine)
- Dropped support for PHP 7.4
- Fixed AST copying
- Fixed possible crash in inherited builtin functions in user classes extending builtin classes due to scope not being updated
This is not an official release of pthreads. This repository is a fork of krakjoe/pthreads, which has been abandoned.
Its use case is primarily PocketMine-MP; while its API currently remains more or less the same as original pthreads, this may change without warning.
4.0.0
Changes since 3.2.0
- PHP 7.4 and 8.0 support
- Dropped support for PHP 7.3 and below
Socket
has been renamed toThreadedSocket
to avoid conflicting with PHP 8's newSocket
class- Added
Threaded->getIterator()
- Many bug fixes, memory usage improvements, and performance improvements
This is not an official release of pthreads. This repository is a fork of krakjoe/pthreads, which has been abandoned.
Its use case is primarily PocketMine-MP; while its API currently remains more or less the same as original pthreads, this may change without warning.