mirror of
https://github.com/boostorg/fiber.git
synced 2026-02-14 00:32:17 +00:00
97 lines
5.8 KiB
HTML
97 lines
5.8 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>Rational</title>
|
|
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
|
<link rel="home" href="../index.html" title="Chapter 1. Fiber">
|
|
<link rel="up" href="../index.html" title="Chapter 1. Fiber">
|
|
<link rel="prev" href="performance.html" title="Performance">
|
|
<link rel="next" href="custom.html" title="Customization">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<table cellpadding="2" width="100%"><tr>
|
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
|
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
|
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
<a name="fiber.rational"></a><a class="link" href="rational.html" title="Rational">Rational</a>
|
|
</h2></div></div></div>
|
|
<h4>
|
|
<a name="fiber.rational.h0"></a>
|
|
<span><a name="fiber.rational.distinction_between_coroutines_and_fibers"></a></span><a class="link" href="rational.html#fiber.rational.distinction_between_coroutines_and_fibers">Distinction
|
|
between coroutines and fibers</a>
|
|
</h4>
|
|
<p>
|
|
The fiber library extends the coroutine library by adding a scheduler and synchronization
|
|
mechanisms.
|
|
</p>
|
|
<pre class="programlisting"><span class="special">*</span> <span class="identifier">a</span> <span class="identifier">coroutine</span> <span class="identifier">yields</span>
|
|
|
|
<span class="special">*</span> <span class="identifier">a</span> <span class="identifier">fiber</span> <span class="identifier">blocks</span>
|
|
</pre>
|
|
<p>
|
|
When a coroutine yields, it passes control directly to its caller (or, in the
|
|
case of symmetric coroutines, a designated other coroutine). When a fiber blocks,
|
|
it implicitly passes control to the fiber scheduler. Coroutines have no scheduler
|
|
because they need no scheduler. <sup>[<a name="fiber.rational.f0" href="#ftn.fiber.rational.f0" class="footnote">2</a>]</sup>.
|
|
</p>
|
|
<h4>
|
|
<a name="fiber.rational.h1"></a>
|
|
<span><a name="fiber.rational.what_about_transactional_memory"></a></span><a class="link" href="rational.html#fiber.rational.what_about_transactional_memory">what
|
|
about transactional memory</a>
|
|
</h4>
|
|
<p>
|
|
GCC support transactional memory since version 4.7. Unfortunately testes showed
|
|
that transactional memory is slower (ca. 4x) than using spinlocks using atomics.
|
|
If transactional memory will be improved (supporting hybrid tm), spinlocks
|
|
will be replaced by __transaction_atomic{} statements surrounding the critical
|
|
sections.
|
|
</p>
|
|
<h4>
|
|
<a name="fiber.rational.h2"></a>
|
|
<span><a name="fiber.rational.synchronization_between_fibers_running_in_different_threads"></a></span><a class="link" href="rational.html#fiber.rational.synchronization_between_fibers_running_in_different_threads">synchronization
|
|
between fibers running in different threads</a>
|
|
</h4>
|
|
<p>
|
|
Synchronization classes from <a href="../../../../../libs/thread/index.html" target="_top">Boost.Thread</a>
|
|
do block the entire thread. In contrast to this the synchronization clases
|
|
from <span class="bold"><strong>Boost.Fiber</strong></span> do block only the fiber,
|
|
so that the thread is able to schedule and run other fibers in the meantime.
|
|
The synchronization classes from <span class="bold"><strong>Boost.Fiber</strong></span>
|
|
are designed to be thread-safe, e.g. it is possible to synchronize fibers running
|
|
in different schedulers (different threads) or running int the same scheduler
|
|
(same thread).
|
|
</p>
|
|
<div class="footnotes">
|
|
<br><hr width="100" align="left">
|
|
<div class="footnote"><p><sup>[<a name="ftn.fiber.rational.f0" href="#fiber.rational.f0" class="para">2</a>] </sup>
|
|
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4024.pdf" target="_top">'N4024:
|
|
Distinguishing coroutines and fibers'</a>
|
|
</p></div>
|
|
</div>
|
|
</div>
|
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
<td align="left"></td>
|
|
<td align="right"><div class="copyright-footer">Copyright © 2013 Oliver Kowalke<p>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|
</p>
|
|
</div></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="performance.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|