From: yizhiren Date: Tue, 15 Nov 2016 00:19:37 +0000 (-0800) Subject: correct the description about the thread to run X-Git-Tag: v2016.11.21.00~36 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9ea8c6c7894b7df87a178f6653017483ce8c3a53;p=folly.git correct the description about the thread to run Summary: exchange A and B in this sentence : "Or, maybe x will execute in Thread B, but y and/or z will execute in Thread A". I think x in B and y,z in A is impossible. but x in A and y,z in B is possible, in that example. Closes https://github.com/facebook/folly/pull/514 Reviewed By: yfeldblum Differential Revision: D4176766 Pulled By: Orvid fbshipit-source-id: cf3a47a30d7e43e5291d6b6401198025beba33f8 --- diff --git a/folly/futures/README.md b/folly/futures/README.md index a9d7d88e..381070e5 100644 --- a/folly/futures/README.md +++ b/folly/futures/README.md @@ -159,7 +159,7 @@ Although inspired by the C++11 std::future interface, it is not a drop-in replac p.setValue(); -

This is legal and technically threadsafe. However, it is important to realize that you do not know in which thread x, y, and/or z will execute. Maybe they will execute in Thread A when p.setValue() is called. Or, maybe they will execute in Thread B when f.then is called. Or, maybe x will execute in Thread B, but y and/or z will execute in Thread A. There's a race between setValue and then—whichever runs last will execute the callback. The only guarantee is that one of them will run the callback.

+

This is legal and technically threadsafe. However, it is important to realize that you do not know in which thread x, y, and/or z will execute. Maybe they will execute in Thread A when p.setValue() is called. Or, maybe they will execute in Thread B when f.then is called. Or, maybe x will execute in Thread A, but y and/or z will execute in Thread B. There's a race between setValue and then—whichever runs last will execute the callback. The only guarantee is that one of them will run the callback.

Naturally, you will want some control over which thread executes callbacks. We have a few mechanisms to help.