Hack has introduced asynchronous programming. This is really great but it is not really documented at the moment. Not at all actually… I’ve done some experimenting and I will try to introduce you to the new concept.
There is two new keywords async and await. Async is used to declare a function as asynchronous. You need to declare the function with async if you want to run it in parallel with other functions. Every async function will return an Awaitable.
Instead of the join function you may use the await keyword to suspend the execution of the async function waiting for the WaitHandle to complete.
There is also a series of object inheriting WaitHandle which you may us. Below is an example where you stack up asynchronous calls in a GenVectorWaitHandle and execute them all at once.
Notice the last 5 lines in the output. The threads started at the very same time but completed at random order.
I think this feature need some more work before anyone should use it in production. We also need some more documentation on hacklang.org.
The Symfony Runtime component is AWESOME. I did a talk about it at
Symfony World 2021 where I explain how and
why it works. I spent a lot of time on the cont...
The lock component have saved me so many times. It helps me with race conditions,
it makes my code simpler and my application more reliable. I’m using it to ...
I’ve been blogging now and then for over a decade now. I have used Drupal, Wordpress,
plain HTML files, static generators as Jekyll and Sculpin. I’ve also us...
It has been one year since Jérémy Derussé and I started to work on a new API client
for AWS. At the time we could never have imagined how popular it would be...
Leave a Comment