FIbers promise.

201 views
Skip to first unread message

Christian Rivasseau

unread,
Oct 26, 2016, 5:31:08 PM10/26/16
to Folly: the Facebook Open-source LibrarY
Hi everybody,

Thanks for the folly library.

I am a little confused with "folly/futures/Promise.h" and "folly/fibers/Promise.h";
What's the point of having 2 classes given that the fibers docs specifically state that

The good news are, folly::Future is already fibers-compatible.


When would one prefer fibers::Promise over folly::Promise?
Are there any plans to unite the 2?

Thanks a lot,

sanj...@gmail.com

unread,
Oct 27, 2016, 1:55:33 AM10/27/16
to Folly: the Facebook Open-source LibrarY

You need both.  With fibers, you need fiber-compliant mutexes, futures etc
because scheduling of tasks inside a fiber is co-operative.  Every exposed api
must yield to the FiberManager instead of yielding to the underlying thread scheduler

Christian

unread,
Oct 27, 2016, 4:14:31 AM10/27/16
to faceboo...@googlegroups.com
Sanjos, it seems the doc indicates that regular futures are compliant with fibers?

The good news are, folly::Future is already fibers-compatible....

Calling get() on a folly::Future object will only suspend the calling fiber-task. It won't block the system thread, letting it process other tasks.

--

---
You received this message because you are subscribed to the Google Groups "Folly: the Facebook Open-source LibrarY" group.
To unsubscribe from this group and stop receiving emails from it, send an email to facebook-folly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sanj...@gmail.com

unread,
Oct 27, 2016, 4:42:37 AM10/27/16
to Folly: the Facebook Open-source LibrarY

In the future, please provide a link to the document cited :-)
https://github.com/facebook/folly/blob/master/folly/fibers/README.md

I would have to dig deeper into the implementation to understand how the Future detects whether it being executed in a fiber.  I dont have the time for that right now, but generally speaking, as the doc says they do some magic under-cover using Batons.   Maybe someone else has a more accurate answer.

-Sandeep
To unsubscribe from this group and stop receiving emails from it, send an email to facebook-foll...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages