2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-03 09:42:16 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
nobody
4c5073b43d This commit was manufactured by cvs2svn to create tag
'Version_1_30_2'.

[SVN r19685]
2003-08-18 18:40:31 +00:00
William E. Kempf
7a982cb083 Fixed typo: conditin.hpp.
[SVN r17798]
2003-03-10 15:30:29 +00:00
nobody
215ae5dd53 This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17693]
2003-03-01 19:43:06 +00:00
20 changed files with 57 additions and 166 deletions

View File

@@ -22,14 +22,15 @@ subproject libs/thread/build ;
# Include threads.jam for Boost.Threads global build information.
# This greatly simplifies the Jam code needed to configure the build
# for the various Win32 build types.
import ./threads ;
SEARCH on <module@>threads.jam = $(SUBDIR) ;
include <module@>threads.jam ;
{
template thread_libs
## sources ##
: <template>thread_base
## requirements ##
: <sysinclude>$(BOOST_ROOT)
:
## default build ##
: debug release
;
@@ -41,11 +42,6 @@ import ./threads ;
dll boost_thread
: <template>thread_libs ../src/$(CPP_SOURCES).cpp
: <define>BOOST_THREAD_BUILD_DLL=1
<runtime-link>dynamic
# the common names rule ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
;
stage bin-stage
@@ -54,8 +50,4 @@ import ./threads ;
<tag><debug>"d"
: debug release
;
install thread lib
: <dll>boost_thread
;
}

View File

@@ -1,26 +1,12 @@
import os ;
if [ os.name ] = NT
{
reqts = <link>shared:<define>BOOST_THREAD_BUILD_DLL=1 ;
}
else
{
# Declare the uses system library
lib pthread : : <name>pthread ;
usage = <library>pthread ;
}
# Declare the uses system library
lib pthread : : <name>pthread ;
project boost/thread
: source-location ../src
: usage-requirements $(usage)
: requirements $(reqts) <threading>multi
: default-build <threading>multi
: usage-requirements <library>pthread
;
CPP_SOURCES = condition mutex recursive_mutex thread tss xtime once
exceptions threadmon ;
CPP_SOURCES = condition mutex recursive_mutex thread tss xtime once exceptions ;
lib boost_thread
: $(CPP_SOURCES).cpp
;
lib boost_thread : $(CPP_SOURCES).cpp ;

View File

@@ -28,8 +28,7 @@
"http://www.acm.org/pubs/citations/journals/surveys/1983-15-1/p3-andrews/">
http://www.acm.org/pubs/citations/journals/surveys/1983-15-1/p3-andrews/</a>
<p>Good general background reading. Includes descriptions of Path Expressions,
Message Passing, and Remote Procedure Call in addition to the basics.
Section 3.3 explains why semaphores are considered error prone.</p>
Message Passing, and Remote Procedure Call in addition to the basics.</p>
</td>
</tr>
<tr>
@@ -54,28 +53,12 @@
from event queues and semaphores to critical regions and monitors.&quot;
Includes analysis of why <i>events</i> are considered error-prone. Also
noteworthy because of an introductory quotation from Christopher Alexander;
Brinch Hansen was years ahead of others in recognizing that pattern concepts
Brinch Hansen was years ahead of others in recognizing pattern concepts
applied to software too.</p>
</td>
</tr>
<tr>
<td width="102" valign="top" align="left"><b>[<a name="Brinch-Hansen-02">Brinch
Hansen 02</a>]</b></td>
<td width="645">
Per Brinch Hansen, Ed.,&nbsp; <i>The Origin of Concurrent Programming,
from Semaphores to Remote Procedure Calls</i>, Springer-Verlag, 2002. ISBN
0-387-95401-5.
<a href="http://www.springer-ny.com/detail.tpl?isbn=0387954015">
http://www.springer-ny.com/detail.tpl?isbn=0387954015</a><p>Nineteen of
the original seminal papers by Dijkstra, Brinch Hansen, and Hoare, plus a
current (2001) Overview by Brinch Hansen. Although expensive, it is hard
to imagine anyone who is interested in understanding the underpinnings of
any form of concurrent programming who would not want to own this book.
May not be of interest for those who just want to use Boost.Threads and
don't care about the design issues hidden behind the curtain.</td>
</tr>
<tr>
<td width="102" valign="top" align="left"><b>[<a name=
<td width="102" valign="top" align="left"><b>]<a name=
"Butenhof-97">Butenhof 97</a>]</b></td>
<td width="645">
<p>David R. Butenhof, <cite>Programming with POSIX Threads</cite>, Addison-Wesley
@@ -97,8 +80,7 @@
"http://www.acm.org/classics/feb96/"> http://www.acm.org/classics/feb96/</a></p>
<p>Hoare and Brinch Hansen&#39;s work on Monitors is the basis for reliable
multithreading patterns. This is one of the most often referenced papers
in all of computer science, and with good reason. It is included in [<a href="#Brinch-Hansen-02">Brinch
Hansen 02</a>]</p>
in all of computer science, and with good reason.</p>
</td>
</tr>
<tr>
@@ -167,10 +149,12 @@
be visible on printed copies of this document.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->19 July, 2003<!--webbot bot="Timestamp" endspan i-checksum="21111" -->
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href="mailto:wekempf@cox.net">William E. Kempf</a> and
<a href="../../../people/beman_dawes.html">Beman Dawes</a> 2001-2003. All Rights Reserved.</i></p>
Beman Dawes 2001-2002. All Rights Reserved.</i></p>
<p>Permission to use, copy, modify, distribute and sell this software and its
documentation for any purpose is hereby granted without fee, provided that the
above copyright notice appear in all copies and that both that copyright notice
@@ -178,4 +162,4 @@
makes no representations about the suitability of this software for any purpose.
It is provided &quot;as is&quot; without express or implied warranty.</p>
</body>
</html>
</html>

View File

@@ -163,19 +163,10 @@ private:
by Darryl Green).</p>
<h2><a name="question10"></a>10. Why has class semaphore disappeared?</h2>
<p>Semaphore was removed as too error prone. The same effect can be achieved with
greater safety by the combination of a mutex and a condition variable.
Dijkstra (the semaphore's inventor), Hoare, and Brinch Hansen all depreciated
semaphores and advocated more structured alternatives. In a 1969 letter to
Brinch Hansen, Wirth said &quot;semaphores ... are not suitable for higher level
languages.&quot; [<a href="bibliography.html#Andrews-83">Andrews-83]</a>
summarizes typical errors as &quot;omitting a <b>P</b> or a <b>V</b>, or accidentally
coding a <b>P</b> on one semaphore and a <b>V </b>on on another&quot;, forgetting to
include all references to shared objects in critical sections, and confusion
caused by using the same primitive for &quot;both condition synchronization and
mutual exclusion&quot;.</p>
greater safety by the combination of a mutex and a condition variable.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->19 July, 2003<!--webbot bot="Timestamp" endspan i-checksum="21111" -->
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->09 January, 2003<!--webbot bot="Timestamp" endspan i-checksum="38582" -->
</p>
<p><i>&copy; Copyright <a href="mailto:wekempf@cox.net">William E. Kempf</a> 2001-2002.
All Rights Reserved.</i></p>

View File

@@ -136,7 +136,7 @@
<p><b>Recommendation:</b> For the most portable, yet thread-safe code, use Boost
replacements for the problem functions. See the <a href=
"../../random/index.html">Boost Random Number Library</a> and <a href=
"../../tokenizer/index.html">Boost Tokenizer Library</a>.</p>
"../../tokenizer/index.htm">Boost Tokenizer Library</a>.</p>
<h2><a name="common-gaurantees"></a>Common guarantees for all Boost.Threads components</h2>
<h3><a name="exceptions"></a>Exceptions</h3>
<p><b>Boost.Threads</b> destructors never throw exceptions. Unless otherwise specified,

View File

@@ -21,7 +21,8 @@ subproject libs/thread/example ;
# Include threads.jam for Boost.Threads global build information.
# This greatly simplifies the Jam code needed to configure the build
# for the various Win32 build types.
import ../build/threads ;
SEARCH on <module@>threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include <module@>threads.jam ;
{
template example

View File

@@ -13,9 +13,9 @@
#define BOOST_CONDITION_WEK070601_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/thread/exceptions.hpp>
#include <boost/utility.hpp>

View File

@@ -22,23 +22,4 @@
# define BOOST_THREAD_DECL
#endif // BOOST_THREAD_SHARED_LIB
//
// Automatically link to the correct build variant where possible.
//
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_THREAD_NO_LIB) && !defined(BOOST_THREAD_BUILD_DLL)
//
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_thread
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
# define BOOST_DYN_LINK
//
// And include the header that does the work:
//
#include <boost/config/auto_link.hpp>
#endif // auto-linking disabled
#endif // BOOST_THREAD_CONFIG_WEK1032003_HPP

View File

@@ -10,8 +10,9 @@
// It is provided "as is" without express or implied warranty.
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/thread/detail/config.hpp>

View File

@@ -13,8 +13,9 @@
#define BOOST_MUTEX_WEK070601_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/utility.hpp>
#include <boost/thread/detail/lock.hpp>

View File

@@ -13,8 +13,9 @@
#define BOOST_ONCE_WEK080101_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/thread/detail/config.hpp>

View File

@@ -13,8 +13,9 @@
#define BOOST_RECURSIVE_MUTEX_WEK070601_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/utility.hpp>
#include <boost/thread/detail/lock.hpp>

View File

@@ -13,8 +13,9 @@
#define BOOST_THREAD_WEK070601_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/utility.hpp>
#include <boost/function.hpp>

View File

@@ -13,8 +13,9 @@
#define BOOST_TSS_WEK070601_HPP
#include <boost/config.hpp>
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
#include <boost/utility.hpp>
#include <boost/thread/detail/config.hpp>

View File

@@ -127,7 +127,7 @@ void call_once(void (*func)(), once_flag& flag)
strm << "2AC1A572DB6944B0A65C38C4140AF2F4" << std::hex
<< GetCurrentProcessId() << &flag << std::ends;
unfreezer unfreeze(strm);
HANDLE mutex = CreateMutexA(NULL, FALSE, strm.str());
HANDLE mutex = CreateMutex(NULL, FALSE, strm.str());
#else
std::ostringstream strm;
strm << "2AC1A572DB6944B0A65C38C4140AF2F4" << std::hex
@@ -142,18 +142,7 @@ void call_once(void (*func)(), once_flag& flag)
if (compare_exchange(&flag, 1, 1) == 0)
{
try
{
func();
}
catch (...)
{
res = ReleaseMutex(mutex);
assert(res);
res = CloseHandle(mutex);
assert(res);
throw;
}
func();
InterlockedExchange(&flag, 1);
}

View File

@@ -34,12 +34,12 @@ recursive_mutex::recursive_mutex()
: m_mutex(0), m_count(0)
{
try
{
{
m_mutex = reinterpret_cast<void*>(new CRITICAL_SECTION);
}
catch (...)
{
}
}
catch (...)
{
}
if (!m_mutex)
throw thread_resource_error();
InitializeCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(m_mutex));

View File

@@ -21,10 +21,12 @@ subproject libs/thread/test ;
# Include threads.jam for Boost.Threads global build information.
# This greatly simplifies the Jam code needed to configure the build
# for the various Win32 build types.
import ../build/threads ;
SEARCH on threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include threads.jam ;
# bring in rules for testing
import testing ;
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
include testing.jam ;
{
template test

View File

@@ -1,35 +0,0 @@
# (C) Copyright William E. Kempf 2001. Permission to copy, use, modify, sell
# and distribute this software is granted provided this copyright notice
# appears in all copies. This software is provided "as is" without express or
# implied warranty, and with no claim as to its suitability for any purpose.
#
# Boost.Threads test Jamfile
#
# Additional configuration variables used:
# 1. PTW32 may be used on Win32 platforms to specify that the pthreads-win32
# library should be used instead of "native" threads. This feature is
# mostly used for testing and it's generally recommended you use the
# native threading libraries instead. PTW32 should be set to be a list
# of two strings, the first specifying the installation path of the
# pthreads-win32 library and the second specifying which library
# variant to link against (see the pthreads-win32 documentation).
# Example: jam -sPTW32="c:\pthreads-win32 pthreadVCE.lib"
# bring in rules for testing
import testing ;
project
: requirements <library>../build//boost_thread
<library>../../test/build//boost_unit_test_framework
<threading>multi
;
{
test-suite "threads"
: [ run test_thread.cpp ]
[ run test_mutex.cpp ]
[ run test_condition.cpp ]
[ run test_tss.cpp ]
[ run test_once.cpp ]
[ run test_xtime.cpp ]
;
}

View File

@@ -17,7 +17,6 @@
#include "util.inl"
boost::mutex check_mutex;
boost::mutex tss_mutex;
int tss_instances = 0;
@@ -45,13 +44,7 @@ void test_tss_thread()
for (int i=0; i<1000; ++i)
{
int& n = tss_value->value;
// Don't call BOOST_CHECK_EQUAL directly, as it doesn't appear to
// be thread safe. Must evaluate further.
if (n != i)
{
boost::mutex::scoped_lock lock(check_mutex);
BOOST_CHECK_EQUAL(n, i);
}
BOOST_CHECK_EQUAL(n, i);
++n;
}
}

View File

@@ -22,7 +22,8 @@ subproject libs/thread/tutorial ;
# Include threads.jam for Boost.Threads global build information.
# This greatly simplifies the Jam code needed to configure the build
# for the various Win32 build types.
import ../build/threads ;
SEARCH on <module@>threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include <module@>threads.jam ;
{
template tutorial