Releases: true-async/php-async
v0.3.0 - EXP Release
Stabilization release - 2025-07-16
Added
- Docker support with multi-stage build (Ubuntu 24.04, libuv 1.49, curl 8.10)
- PDO MySQL and MySQLi async support
- TrueAsync API Extensions: Enhanced async API with new object creation and coroutine grouping capabilities
- Added
ZEND_ASYNC_NEW_GROUP()
API for creating CoroutineGroup objects for managing multiple coroutines - Added
ZEND_ASYNC_NEW_FUTURE_OBJ()
andZEND_ASYNC_NEW_CHANNEL_OBJ()
APIs for creating Zend objects from async primitives - Extended
zend_async_task_t
structure withrun
method for thread pool task execution - Enhanced
zend_async_scheduler_register()
function with new API function pointers
- Added
- Multiple Callbacks Per Event Support: Complete redesign of waker trigger system to support multiple callbacks on a single event
- Modified
zend_async_waker_trigger_s
structure to use flexible array member with dynamic capacity - Added
waker_trigger_create()
andwaker_trigger_add_callback()
helper functions for efficient memory management - Implemented single-block memory allocation for better performance (trigger + callback array in one allocation)
- Default capacity starts at 1 and doubles as needed (1 β 2 β 4 β 8...)
- Fixed
coroutine_event_callback_dispose()
to remove only specific callbacks instead of entire events - Breaking Change: Events now persist until all associated callbacks are removed
- Modified
- Bailout Tests: Added 15 tests covering memory exhaustion and stack overflow scenarios in async operations
- Garbage Collection Support: Implemented comprehensive GC handlers for async objects
- Added
async_coroutine_object_gc()
function to track all ZVALs in coroutine structures - Added
async_scope_object_gc()
function to track ZVALs in scope structures - Proper GC tracking for context HashTables (values and keys)
- GC support for finally handlers, exception handlers, and function call parameters
- GC tracking for waker events, internal context, and nested async structures
- Prevents memory leaks in complex async applications with circular references
- Added
- Key Order Preservation: Added
preserveKeyOrder
parameter to async await functions- Added
preserve_key_order
parameter toasync_await_futures()
API function - Added
preserve_key_order
field toasync_await_context_t
structure - Enhanced
awaitAll()
,awaitAllWithErrors()
,awaitAnyOf()
, andawaitAnyOfWithErrors()
functions withpreserveKeyOrder
parameter (defaults totrue
) - Allows controlling whether the original key order is maintained in result arrays
- Added
Fixed
- Memory management improvements for long-running async applications
- Proper cleanup of coroutine and scope objects during garbage collection cycles
- Async Iterator API:
- Fixed iterator state management to prevent memory leaks
- Fixed the
spawnWith()
function for interaction with theScopeProvider
andSpawnStrategy
interface - Build System Fixes:
- Fixed macOS compilation error with missing field initializer in
uv_stdio_container_t
structure (libuv_reactor.c:1956
) - Fixed Windows build script PowerShell syntax error (missing
shell: cmd
directive) - Fixed race condition issues in 10 async test files for deterministic test execution on all platforms
- Fixed macOS compilation error with missing field initializer in
Changed
- Breaking Change: Function Renaming - Major API reorganization for better consistency:
awaitAllFailFirst()
βawaitAllOrFail()
awaitAllWithErrors()
βawaitAll()
awaitAnyOfFailFirst()
βawaitAnyOfOrFail()
awaitAnyOfWithErrors()
βawaitAnyOf()
- Breaking Change:
awaitAll()
Return Format - NewawaitAll()
(formerlyawaitAllWithErrors()
) now returns[results, exceptions]
tuple:- First element
[0]
contains array of successful results - Second element
[1]
contains array of exceptions from failed coroutines - Migration: Update from
$results = awaitAll($coroutines)
to[$results, $exceptions] = awaitAll($coroutines)
- First element
- LibUV requirement increased to β₯ 1.44.0 - Requires libuv version 1.44.0 or later to ensure proper UV_RUN_ONCE behavior and prevent busy loop issues that could cause high CPU usage
- Async Iterator API:
- Proper handling of
REWIND
/NEXT
states in a concurrent environment.
The iterator code now stops iteration in
coroutines if the iterator is in the process of changing its position. - Added functionality for proper handling of exceptions from
Zend iterators
(\Iterator
andgenerators
).
An exception that occurs in the iterator can now be handled by the iterator's owner.
- Proper handling of
Experimental release (fixes)
Bug fixing in the previous release:
- Fixed issue with CURL 8.5
- Fixed warnings for GCC
- Fixed issues with --repeat=2 CLI test mode
Experimental release
π PHP TRUE ASYNC v0.2.0 Release Notes
To build this release, use the corresponding tag from the PHP SRC
project:
https://github.com/true-async/php-src/releases/tag/v0.2.0
Major Architecture & API Enhancement
π― Key Highlights
-
Now asynchronous execution is available at all stages of PHP operation, even in the
register_shutdown
function. -
The key features of the RFC are completed!
β New Features
π‘οΈ Enhanced Exception Handling
- CompositeException - New exception class for handling multiple exceptions in finally blocks
- Automatic exception collection from onFinally handlers in both Scope and Coroutine
- Guaranteed execution of all finally handlers even when exceptions occur
- Methods: addException() and getExceptions() for exception management
π Extended Scope Capabilities
- Complete implementation of onFinally() method for Async\Scope class
- disposeAfterTimeout() method for automatic cleanup with timeout
- awaitAfterCancellation() method for post-cancellation waiting
- Async\protect() function for protecting critical sections
β‘ Coroutine Priority Support
- Priority support in async iterator system
- Coroutine priority support in TrueAsync API
- Optimized execution scheduling based on priority levels
π§ System Improvements
- Async-aware destructor handling - Proper destructor handling in async context via
async_shutdown_destructors
() - Cross-thread trigger event API for inter-thread communication
- Signal handlers support (UNIX systems)
- Enhanced Iterator API integration with run() and run_in_coroutine() methods
- Asynchronous execution is available at all stages of PHP operation, even in the
register_shutdown
function.
π Architecture Changes
- Enhanced ZEND_ASYNC_NEW_SCOPE API - Create Scope without Zend object for internal use
- Refactored catch_or_cancel logic according to RFC scope behavior
- Optimized iterator module and data structures
- Improved exception handling and cancellation logic
- Enhanced Context API behavior for Scope operations
π Bug Fixes
- Multiple fixes for Scope dispose operations
- Fixed scope_try_to_dispose logic
- Resolved race conditions in process waiting (libuv)
- Memory cleanup fixes for reactor shutdown
- Build issues resolution for Scope
- Context logic fixes with NULL scope
- Iterator bugs and coroutine issues resolved
- Stream tests and DNS tests fixes
- ZEND_ASYNC_IS_OFF issues resolved
π Testing Suite
Comprehensive test coverage includes:
- 150+ tests across all key areas
- DNS tests (15 files) including IPv6 support
- CURL tests with async support
- Socket and Stream operation tests
- Output buffer isolation tests between coroutines
- Exception handling and cancellation tests
- Scope lifecycle and finally handler tests
ποΈ Build Process
The --enable-experimental-async-api
option is no longer needed as the Async API
is now enabled by default in the core.
π Compatibility
- PHP 8.5.0+ (official support)
- LibUV as primary reactor implementation
- Windows and Unix/macOS platforms
- IPv6 support for DNS and socket operations
π Performance Improvements
- Optimized iterator module performance
- Enhanced memory management with proper separation
- Improved circular buffer behavior during relocation and resizing
- Refactored timeout object implementation
- Better scheduler graceful shutdown logic
π What's Next
This release represents a significant step towards stabilizing PHP's async ecosystem. The core API is now mature enough for production testing, with comprehensive exception handling, proper resource management, and
extensive test coverage.
π Migration Guide
From v0.1.0 to v0.2.0
- Build Process: Remove --enable-experimental-async-api from your build scripts
- Exception Handling: Update error handling to work with CompositeException
- Scope API: Leverage new onFinally(), disposeAfterTimeout(), and awaitAfterCancellation() methods
- Priority Support: Optionally implement coroutine priorities for better performance
Breaking Changes
- None - this release maintains backward compatibility with v0.1.0
PHP TRUE ASYNC β modern async PHP, today!
v0.1.0
Core functions for working with the PHP engine
v0.0.1
Simplified partial core functionality with tests.