Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/thread/doc/design.xml @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 8.0 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
3  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd" [
4  <!ENTITY % thread.entities SYSTEM "entities.xml">
5  %thread.entities;
6]>
7<!-- Copyright (c) 2002-2003 William E. Kempf, Michael Glassford
8     Subject to the Boost Software License, Version 1.0.
9     (See accompanying file LICENSE-1.0 or  http://www.boost.org/LICENSE-1.0)
10-->
11<section id="thread.design" last-revision="$Date: 2006/10/15 14:52:53 $">
12  <title>Design</title>
13  <para>With client/server and three-tier architectures becoming common place
14  in today's world, it's becoming increasingly important for programs to be
15  able to handle parallel processing. Modern day operating systems usually
16  provide some support for this through native thread APIs. Unfortunately,
17  writing portable code that makes use of parallel processing in C++ is made
18  very difficult by a lack of a standard interface for these native APIs.
19  Further, these APIs are almost universally C APIs and fail to take
20  advantage of C++'s strengths, or to address concepts unique to C++, such as
21  exceptions.</para>
22  <para>The &Boost.Thread; library is an attempt to define a portable interface
23  for writing parallel processes in C++.</para>
24  <section id="thread.design.goals">
25    <title>Goals</title>
26    <para>The &Boost.Thread; library has several goals that should help to set
27        it apart from other solutions. These goals are listed in order of precedence
28        with full descriptions below.
29    <variablelist>
30          <varlistentry>
31            <term>Portability</term>
32                <listitem>
33          <para>&Boost.Thread; was designed to be highly portable. The goal is
34                  for the interface to be easily implemented on any platform that
35                  supports threads, and possibly even on platforms without native thread
36                  support.</para>
37                </listitem>
38          </varlistentry>
39          <varlistentry>
40        <term>Safety</term>
41        <listitem>
42          <para>&Boost.Thread; was designed to be as safe as possible. Writing
43                  <link linkend="thread.glossary.thread-safe">thread-safe</link>
44                  code is very difficult and successful libraries must strive to
45                  insulate the programmer from dangerous constructs as much as
46                  possible. This is accomplished in several ways:
47          <itemizedlist>
48            <listitem>
49              <para>C++ language features are used to make correct usage easy
50                          (if possible) and error-prone usage impossible or at least more
51                          difficult. For example, see the <link
52                          linkend="thread.concepts.Mutex">Mutex</link> and <link
53                          linkend="thread.concepts.Lock">Lock</link> designs, and note
54                          how they interact.</para>
55            </listitem>
56            <listitem>
57              <para>Certain traditional concurrent programming features are
58                          considered so error-prone that they are not provided at all. For
59                          example, see <xref linkend="thread.rationale.events" />.</para>
60            </listitem>
61            <listitem>
62              <para>Dangerous features, or features which may be misused, are
63              identified as such in the documentation to make users aware of
64              potential pitfalls.</para>
65            </listitem>
66          </itemizedlist></para>
67                </listitem>
68          </varlistentry>
69      <varlistentry>
70            <term>Flexibility</term>
71                <listitem>
72                  <para>&Boost.Thread; was designed to be flexible. This goal is often
73                  at odds with <emphasis>safety</emphasis>. When functionality might be
74                  compromised by the desire to keep the interface safe, &Boost.Thread;
75                  has been designed to provide the functionality, but to make it's use
76                  prohibitive for general use. In other words, the interfaces have been
77                  designed such that it's usually obvious when something is unsafe, and
78                  the documentation is written to explain why.</para>
79        </listitem>
80          </varlistentry>
81      <varlistentry>
82        <term>Efficiency</term>
83                <listitem>
84          <para>&Boost.Thread; was designed to be as efficient as
85                  possible. When building a library on top of another library there is
86                  always a danger that the result will be so much slower than the
87                  "native" API that programmers are inclined to ignore the higher level
88                  API. &Boost.Thread; was designed to minimize the chances of this
89                  occurring. The interfaces have been crafted to allow an implementation
90                  the greatest chance of being as efficient as possible. This goal is
91                  often at odds with the goal for <emphasis>safety</emphasis>. Every
92                  effort was made to ensure efficient implementations, but when in
93                  conflict <emphasis>safety</emphasis> has always taken
94                  precedence.</para>
95        </listitem>
96          </varlistentry>
97    </variablelist></para>
98  </section>
99  <section>
100    <title>Iterative Phases</title>
101    <para>Another goal of &Boost.Thread; was to take a dynamic, iterative
102        approach in its development. The computing industry is still exploring the
103        concepts of parallel programming. Most thread libraries supply only simple
104        primitive concepts for thread synchronization. These concepts are very
105        simple, but it is very difficult to use them safely or to provide formal
106        proofs for constructs built on top of them. There has been a lot of research
107        into other concepts, such as in "Communicating Sequential Processes."
108        &Boost.Thread; was designed in iterative steps, with each step providing
109        the building blocks necessary for the next step and giving the researcher
110        the tools necessary to explore new concepts in a portable manner.</para>
111    <para>Given the goal of following a dynamic, iterative approach
112        &Boost.Thread; shall go through several growth cycles. Each phase in its
113        development shall be roughly documented here.</para>
114  </section>
115  <section>
116    <title>Phase 1, Synchronization Primitives</title>
117    <para>Boost is all about providing high quality libraries with
118        implementations for many platforms. Unfortunately, there's a big problem
119        faced by developers wishing to supply such high quality libraries, namely
120        thread-safety. The C++ standard doesn't address threads at all, but real
121        world programs often make use of native threading support. A portable
122        library that doesn't address the issue of thread-safety is therefore not
123        much help to a programmer who wants to use the library in his multithreaded
124        application. So there's a very great need for portable primitives that will
125        allow the library developer to create <link
126        linkend="thread.glossary.thread-safe">thread-safe</link>
127        implementations. This need far out weighs the need for portable methods to
128        create and manage threads.</para>
129    <para>Because of this need, the first phase of &Boost.Thread; focuses
130        solely on providing portable primitive concepts for thread
131        synchronization. Types provided in this phase include the
132        <classname>boost::mutex</classname>,
133        <classname>boost::try_mutex</classname>,
134        <classname>boost::timed_mutex</classname>,
135        <classname>boost::recursive_mutex</classname>,
136        <classname>boost::recursive_try_mutex</classname>,
137        <classname>boost::recursive_timed_mutex</classname>, and
138        <classname>boost::lock_error</classname>. These are considered the "core"
139        synchronization primitives, though there are others that will be added in
140        later phases.</para>
141  </section>
142  <section id="thread.design.phase2">
143    <title>Phase 2, Thread Management and Thread Specific Storage</title>
144    <para>This phase addresses the creation and management of threads and
145    provides a mechanism for thread specific storage (data associated with a
146    thread instance). Thread management is a tricky issue in C++, so this
147    phase addresses only the basic needs of multithreaded program. Later
148    phases are likely to add additional functionality in this area. This
149    phase of &Boost.Thread; adds the <classname>boost::thread</classname> and
150        <classname>boost::thread_specific_ptr</classname> types. With these
151        additions the &Boost.Thread; library can be considered minimal but
152        complete.</para>
153  </section>
154  <section>
155    <title>The Next Phase</title>
156    <para>The next phase will address more advanced synchronization concepts,
157    such as read/write mutexes and barriers.</para>
158  </section>
159</section>
Note: See TracBrowser for help on using the repository browser.