Re: [RFC] Fibers
| From: | Aaron Piotrowski | Date: | Wed, 23 Dec 2020 06:30:13 +0000 |
| Subject: | Re: [RFC] Fibers | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112608@lists.php.net to get a copy of this message | ||
Hi Mike,
> On Dec 21, 2020, at 7:38 PM, Mike Schinkel <mike@newclarity.net> wrote:
>
> Would it be appropriate of me to ask for a section that discusses how that might be done in
> user space in the RFC, at least with some simple pseudo-code, or if is it non-trivial than a link to
> where it is discussed in depth?
Absolutely! I added a short example implementation of a mutex to the RFC under https://wiki.php.net/rfc/fibers#how_do_various_fibers_access_the_same_memory.
The code uses a simple queue of fibers waiting to access the mutex to acquire and release the lock.
A channel might be implemented with a queue of messages where the receiving fiber suspends if the
queue is empty. Sending a message on the channel would resume a suspended fiber that was waiting to
receive a message.
Hopefully that helps. If something is still unclear or an additional example would help, don't
hesitate to ask.
Cheers!
Aaron Piotrowski