Hack Adds Async Cooperative Multitasking For Fake Multi-Threading

Written by Michael Larabel in Free Software on 6 December 2014 at 08:01 AM EST. 6 Comments
FREE SOFTWARE
The latest addition to Facebook's PHP-based Hack programming language is an interesting concept of cooperative multitasking for providing threading-like capabilities while only really executing one piece of code at a time.

Hack's Async Cooperative Multitasking support isn't for providing real multi-threaded support but only executes one block of code at a time while being smarter about downtime for code while being blocked by waiting on requests. Namely, while one block of code could be waiting on an HTTP request or database query to be processed, another block of Hack code can be running in the intervening time.

The cooperative multitasking allows for other code to be executed while waiting for HTTP/database responses to be processed. Supported Hack code can be annotated with marking a function as "async" and use the await, WaitHandle, and Awaitable structures.

In the near-term, Facebook developers are looking to allow the cooperative multitasking to work for Streams, MySQL, WebScaleSQL, and memcached. The async feature is present in HHVM 3.5 and is still considered under active development.

Those wishing to learn more about Hack's cooperative multitasking can read this HHVM blog post.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week