You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/true_async_api/api-reference.rst
+62-61Lines changed: 62 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,12 @@
2
2
API Reference
3
3
###############
4
4
5
-
This section provides comprehensive documentation for the TrueAsync API functions, macros, and data structures based on the actual implementation in ``Zend/zend_async_API.h``.
5
+
This section provides comprehensive documentation for the TrueAsync API functions, macros, and data
6
+
structures based on the actual implementation in ``Zend/zend_async_API.h``.
6
7
7
-
******************
8
+
*************
8
9
API Version
9
-
******************
10
+
*************
10
11
11
12
.. code:: c
12
13
@@ -15,9 +16,9 @@ This section provides comprehensive documentation for the TrueAsync API function
15
16
#define ZEND_ASYNC_API_VERSION_MINOR 4
16
17
#define ZEND_ASYNC_API_VERSION_PATCH 0
17
18
18
-
********************
19
+
*****************
19
20
Core API Macros
20
-
********************
21
+
*****************
21
22
22
23
Enablement Check
23
24
================
@@ -26,18 +27,18 @@ Enablement Check
26
27
27
28
ZEND_ASYNC_IS_ENABLED()
28
29
29
-
Returns ``true`` if async functionality is available, ``false`` otherwise.
30
-
Always check this before using any async APIs.
30
+
Returns ``true`` if async functionality is available, ``false`` otherwise. Always check this before
31
+
using any async APIs.
31
32
32
33
.. code:: c
33
34
34
35
ZEND_ASYNC_REACTOR_IS_ENABLED()
35
36
36
37
Returns ``true`` if reactor (event loop) is available and functional.
37
38
38
-
*********************
39
+
**********************
39
40
Coroutine Operations
40
-
*********************
41
+
**********************
41
42
42
43
Coroutine Creation
43
44
==================
@@ -52,11 +53,11 @@ Coroutine Creation
52
53
53
54
Creates and spawns new coroutines with various configuration options:
54
55
55
-
* ``ZEND_ASYNC_SPAWN()`` - Create coroutine with default settings
56
-
* ``ZEND_ASYNC_SPAWN_WITH(scope)`` - Create coroutine within specific scope
57
-
* ``ZEND_ASYNC_SPAWN_WITH_PROVIDER(scope_provider)`` - Use scope provider object
58
-
* ``ZEND_ASYNC_SPAWN_WITH_PRIORITY(priority)`` - Set coroutine priority
59
-
* ``ZEND_ASYNC_SPAWN_WITH_SCOPE_EX(scope, priority)`` - Both scope and priority
56
+
- ``ZEND_ASYNC_SPAWN()`` - Create coroutine with default settings
57
+
- ``ZEND_ASYNC_SPAWN_WITH(scope)`` - Create coroutine within specific scope
58
+
- ``ZEND_ASYNC_SPAWN_WITH_PROVIDER(scope_provider)`` - Use scope provider object
59
+
- ``ZEND_ASYNC_SPAWN_WITH_PRIORITY(priority)`` - Set coroutine priority
60
+
- ``ZEND_ASYNC_SPAWN_WITH_SCOPE_EX(scope, priority)`` - Both scope and priority
60
61
61
62
**Priority levels:**
62
63
@@ -89,8 +90,8 @@ Adds coroutine to execution queue for scheduling.
89
90
90
91
Suspends current coroutine execution:
91
92
92
-
* ``SUSPEND()`` - Normal suspension
93
-
* ``RUN_SCHEDULER_AFTER_MAIN()`` - Suspend from main context
93
+
- ``SUSPEND()`` - Normal suspension
94
+
- ``RUN_SCHEDULER_AFTER_MAIN()`` - Suspend from main context
94
95
95
96
Coroutine Control
96
97
=================
@@ -102,8 +103,8 @@ Coroutine Control
102
103
103
104
Resume coroutine execution:
104
105
105
-
* ``RESUME(coroutine)`` - Normal resume
106
-
* ``RESUME_WITH_ERROR(coroutine, error, transfer_error)`` - Resume with exception
106
+
- ``RESUME(coroutine)`` - Normal resume
107
+
- ``RESUME_WITH_ERROR(coroutine, error, transfer_error)`` - Resume with exception
107
108
108
109
.. code:: c
109
110
@@ -112,12 +113,12 @@ Resume coroutine execution:
112
113
113
114
Cancel coroutine execution:
114
115
115
-
* ``CANCEL()`` - Cancel with default safety
116
-
* ``CANCEL_EX()`` - Cancel with explicit safety flag
116
+
- ``CANCEL()`` - Cancel with default safety
117
+
- ``CANCEL_EX()`` - Cancel with explicit safety flag
117
118
118
-
********************
119
+
***********
119
120
Scope API
120
-
********************
121
+
***********
121
122
122
123
Scope Creation
123
124
==============
@@ -129,30 +130,30 @@ Scope Creation
129
130
130
131
Create new async scopes for coroutine isolation:
131
132
132
-
* ``NEW_SCOPE(parent)`` - Create scope with parent reference
133
-
* ``NEW_SCOPE_WITH_OBJECT(parent)`` - Create scope backed by zend_object
133
+
- ``NEW_SCOPE(parent)`` - Create scope with parent reference
134
+
- ``NEW_SCOPE_WITH_OBJECT(parent)`` - Create scope backed by zend_object
134
135
135
136
Scope Flags
136
137
===========
137
138
138
139
.. code:: c
139
140
140
141
#define ZEND_ASYNC_SCOPE_IS_CLOSED(scope)
141
-
#define ZEND_ASYNC_SCOPE_IS_CANCELLED(scope)
142
+
#define ZEND_ASYNC_SCOPE_IS_CANCELLED(scope)
142
143
#define ZEND_ASYNC_SCOPE_IS_DISPOSING(scope)
143
144
144
145
Check scope status:
145
146
146
-
* ``IS_CLOSED`` - Scope has been closed
147
-
* ``IS_CANCELLED`` - Scope was cancelled
148
-
* ``IS_DISPOSING`` - Scope is being disposed
147
+
- ``IS_CLOSED`` - Scope has been closed
148
+
- ``IS_CANCELLED`` - Scope was cancelled
149
+
- ``IS_DISPOSING`` - Scope is being disposed
149
150
150
-
********************
151
+
***********
151
152
Event API
152
-
********************
153
+
***********
153
154
154
155
Event Lifecycle
155
-
================
156
+
===============
156
157
157
158
All async events implement these core function pointers:
158
159
@@ -163,7 +164,7 @@ All async events implement these core function pointers:
Copy file name to clipboardExpand all lines: docs/source/true_async_api/architecture.rst
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,28 +3,25 @@
3
3
##############
4
4
5
5
The TrueAsync API follows a clean separation-of-concerns architecture that splits API definition
6
-
from implementation. This design enables modularity, testability, and support for multiple
7
-
backend implementations.
6
+
from implementation. This design enables modularity, testability, and support for multiple backend
7
+
implementations.
8
8
9
9
The **True Async API** is divided into three main functional blocks:
10
10
11
-
- **Scheduler**
12
-
Manages coroutines and the main event loop.
13
-
14
-
- **Reactor**
15
-
Handles everything related to input/output (I/O), including sockets, timers, and file descriptors.
16
-
17
-
- **Thread Pool**
18
-
Allows execution of blocking or heavy tasks in a thread pool.
11
+
- **Scheduler** Manages coroutines and the main event loop.
12
+
- **Reactor** Handles everything related to input/output (I/O), including sockets, timers, and file
13
+
descriptors.
14
+
- **Thread Pool** Allows execution of blocking or heavy tasks in a thread pool.
19
15
20
16
---
21
17
22
18
## Implementation Flexibility
23
19
24
-
The True Async API provides clearly separated interfaces for each block, allowing them to be implemented independently—even across different PHP extensions. For example:
20
+
The True Async API provides clearly separated interfaces for each block, allowing them to be
21
+
implemented independently—even across different PHP extensions. For example:
25
22
26
-
- The Scheduler can be implemented as part of the PHP core.
27
-
- The Reactor can be implemented in a separate extension using `libuv`.
28
-
- The Thread Pool can be based on native threads or a library like `pthreads`.
23
+
- The Scheduler can be implemented as part of the PHP core.
24
+
- The Reactor can be implemented in a separate extension using `libuv`.
25
+
- The Thread Pool can be based on native threads or a library like `pthreads`.
29
26
30
-
This approach gives developers maximum flexibility and control over asynchronous execution.
27
+
This approach gives developers maximum flexibility and control over asynchronous execution.
0 commit comments