Skip to content

Experimental release

Compare
Choose a tag to compare
@EdmondDantes EdmondDantes released this 30 Jun 12:08
· 209 commits to main since this 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

  1. Build Process: Remove --enable-experimental-async-api from your build scripts
  2. Exception Handling: Update error handling to work with CompositeException
  3. Scope API: Leverage new onFinally(), disposeAfterTimeout(), and awaitAfterCancellation() methods
  4. 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!