> On Dec 17, 2020, at 11:30 AM, Aaron Piotrowski <aa...@trowski.com> wrote:
> 
> Hello everyone!
> 
> I would like to introduce an RFC for adding full-stack fibers to PHP: 
> https://wiki.php.net/rfc/fibers
> 
> Fibers are primarily used to implement green-threads or coroutines for 
> asynchronous I/O. Fibers are similar to threads, except fibers exist within a 
> single thread and require cooperative scheduling of the fibers by the 
> process. Since fibers do not require a full CPU context switch, they are 
> lightweight and more performant than multi-processing or threading for 
> awaiting I/O.
> 
> An implementation as an extension is at https://github.com/amphp/ext-fiber
> 
> Fibers are a complex feature. The RFC contains many examples and links to 
> code using fibers to help explain and demonstrate what is possible, however 
> I’m certain many more questions and concerns will arise. Looking forward to 
> feedback and discussion.
> 

This is interesting, and potentially very useful.

I am curious about how you propose access to shared memory across fibers?  What 
will happen if two fibers try to update a $GLOBALS variable at the same time?  
Or a property of the same object?  How will developers manage that?

-Mike

P.S. Have you considered concurrency functionality like in GoLang[1] e.g. 
channels, where the mantra is "Do not communicate by sharing memory; instead, 
share memory by communicating?"

[1] 
https://medium.com/@thejasbabu/concurrency-in-go-e4a61ec96491#:~:text=Do%20not%20communicate%20by%20sharing,race%20conditions%2C%20memory%20management%20etc.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to