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
</span><span class="n">p</span><span class="p">.</span><span class="n">setValue</span><span class="p">(</span><span class="p">)</span><span class="p">;</span><span class="">
</span></pre></div>
-<p>This is legal and technically threadsafe. However, it is important to realize that you do not know in which thread <tt>x</tt>, <tt>y</tt>, and/or <tt>z</tt> will execute. Maybe they will execute in Thread A when <tt>p.setValue()</tt> is called. Or, maybe they will execute in Thread B when <tt>f.then</tt> is called. Or, maybe <tt>x</tt> will execute in Thread B, but <tt>y</tt> and/or <tt>z</tt> will execute in Thread A. There's a race between <tt>setValue</tt> and <tt>then</tt>—whichever runs last will execute the callback. The only guarantee is that one of them will run the callback.</p>
+<p>This is legal and technically threadsafe. However, it is important to realize that you do not know in which thread <tt>x</tt>, <tt>y</tt>, and/or <tt>z</tt> will execute. Maybe they will execute in Thread A when <tt>p.setValue()</tt> is called. Or, maybe they will execute in Thread B when <tt>f.then</tt> is called. Or, maybe <tt>x</tt> will execute in Thread A, but <tt>y</tt> and/or <tt>z</tt> will execute in Thread B. There's a race between <tt>setValue</tt> and <tt>then</tt>—whichever runs last will execute the callback. The only guarantee is that one of them will run the callback.</p>
<p>Naturally, you will want some control over which thread executes callbacks. We have a few mechanisms to help.</p>