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

Compare commits

...

19 Commits

Author SHA1 Message Date
John Maddock
3ef8e9f6a0 merged auto-linking support from main branch
[SVN r21595]
2004-01-11 15:56:00 +00:00
nobody
bd65d75841 This commit was manufactured by cvs2svn to create branch 'RC_1_31_0'.
[SVN r21427]
2003-12-30 12:10:04 +00:00
Rene Rivera
515590495a Fix tabs in file.
[SVN r21399]
2003-12-26 23:26:49 +00:00
John Maddock
7221bca909 Added <runtime-link>dynamic requirement to dll build.
[SVN r21355]
2003-12-20 12:55:40 +00:00
John Maddock
ed64a8cd12 Changed #errors to use new requires_threads.hpp header instead.
[SVN r21351]
2003-12-20 11:56:37 +00:00
Beman Dawes
cbd30d22ff fix links broken by index.htm to index.html renaming
[SVN r21233]
2003-12-12 00:00:13 +00:00
Dave Abrahams
0c74dbd436 * Fixed Boost.Thread jamfile to add the missing #include paths
* Modified Python testing code to use the facilities of testing.jam,
  so that it can be processed with process_jam_log

* Updated Python library tests to use a test suite

* Added Python test suite to status/Jamfile

* Added --run-all-tests option to force tests to run even when up-to-date.


Also,
boost-base.jam:

    Added some missing rule signatures

    RUN_LD_LIBRARY_PATH became LINK_LIBPATH because it was only really
    used during linking.

    Reformed the movement of path variables up the dependency graph

    Removed the defunct Run rule

    Set up generalized constants for path manipulation

darwin-tools.jam, gcc-tools.jam:

   use LINK_LIBPATH

python.jam:

   Reformed the choice of Python executable

testing.jam:

   Refactored testing code so it could be used for Python

   Now building all environment variable setup code ahead of time

   RUN_TEST became TEST_EXE


[SVN r20815]
2003-11-15 15:41:41 +00:00
Rene Rivera
49356cc931 Add install definitions for new common install configuration.
[SVN r20409]
2003-10-19 19:52:56 +00:00
Vladimir Prus
ceee6e8b17 Add V2 Jamfile
[SVN r20271]
2003-10-07 08:10:42 +00:00
Dave Abrahams
61ab2754d2 Use the import rule
[SVN r19968]
2003-09-08 17:38:49 +00:00
Dave Abrahams
2de3df61e8 Updates for Win32 builds
[SVN r19727]
2003-08-22 03:41:42 +00:00
Dave Abrahams
b84d7aa06d Port "conditin.hpp" typo fix over from Version_1_30_2
[SVN r19725]
2003-08-21 22:51:38 +00:00
Dave Abrahams
ed48f900a3 Compile on Windows; add some requirements and default-build (though
the latter shouldn't be neccessary?!)


[SVN r19715]
2003-08-20 13:51:35 +00:00
Beman Dawes
d197a49707 fix typo
[SVN r19214]
2003-07-19 14:21:00 +00:00
Beman Dawes
b8ccaa3bf6 Add Wirth's view of semaphores
[SVN r19213]
2003-07-19 14:08:32 +00:00
Beman Dawes
507a684b21 Add [Brinch Hansen 02]
[SVN r19212]
2003-07-19 14:07:50 +00:00
Beman Dawes
c969c9387a Expand semaphore FAQ
[SVN r18952]
2003-07-07 00:39:06 +00:00
William E. Kempf
1709db4953 Fixed exception handling bug in once.cpp.
[SVN r18933]
2003-07-03 13:31:27 +00:00
William E. Kempf
4d1c9ba316 Attempted to fix race condition in test_tss.cpp.
[SVN r18838]
2003-06-18 20:50:15 +00:00
21 changed files with 167 additions and 58 deletions

View File

@@ -22,15 +22,14 @@ 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.
SEARCH on <module@>threads.jam = $(SUBDIR) ;
include <module@>threads.jam ;
import ./threads ;
{
template thread_libs
## sources ##
: <template>thread_base
## requirements ##
:
: <sysinclude>$(BOOST_ROOT)
## default build ##
: debug release
;
@@ -42,6 +41,11 @@ include <module@>threads.jam ;
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
@@ -50,4 +54,8 @@ include <module@>threads.jam ;
<tag><debug>"d"
: debug release
;
install thread lib
: <dll>boost_thread
;
}

View File

@@ -1,12 +1,26 @@
import os ;
# Declare the uses system library
lib pthread : : <name>pthread ;
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 ;
}
project boost/thread
: source-location ../src
: usage-requirements <library>pthread
: usage-requirements $(usage)
: requirements $(reqts) <threading>multi
: default-build <threading>multi
;
CPP_SOURCES = condition mutex recursive_mutex thread tss xtime once exceptions ;
CPP_SOURCES = condition mutex recursive_mutex thread tss xtime once
exceptions threadmon ;
lib boost_thread : $(CPP_SOURCES).cpp ;
lib boost_thread
: $(CPP_SOURCES).cpp
;

View File

@@ -28,7 +28,8 @@
"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.</p>
Message Passing, and Remote Procedure Call in addition to the basics.
Section 3.3 explains why semaphores are considered error prone.</p>
</td>
</tr>
<tr>
@@ -53,12 +54,28 @@
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 pattern concepts
Brinch Hansen was years ahead of others in recognizing that pattern concepts
applied to software too.</p>
</td>
</tr>
<tr>
<td width="102" valign="top" align="left"><b>]<a name=
<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=
"Butenhof-97">Butenhof 97</a>]</b></td>
<td width="645">
<p>David R. Butenhof, <cite>Programming with POSIX Threads</cite>, Addison-Wesley
@@ -80,7 +97,8 @@
"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.</p>
in all of computer science, and with good reason. It is included in [<a href="#Brinch-Hansen-02">Brinch
Hansen 02</a>]</p>
</td>
</tr>
<tr>
@@ -149,12 +167,10 @@
be visible on printed copies of this document.</p>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
05 November, 2001
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->19 July, 2003<!--webbot bot="Timestamp" endspan i-checksum="21111" -->
</p>
<p><i>&copy; Copyright <a href="mailto:wekempf@cox.net">William E. Kempf</a> and
Beman Dawes 2001-2002. All Rights Reserved.</i></p>
<a href="../../../people/beman_dawes.html">Beman Dawes</a> 2001-2003. 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
@@ -162,4 +178,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,10 +163,19 @@ 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.</p>
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>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->09 January, 2003<!--webbot bot="Timestamp" endspan i-checksum="38582" -->
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->19 July, 2003<!--webbot bot="Timestamp" endspan i-checksum="21111" -->
</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.htm">Boost Tokenizer Library</a>.</p>
"../../tokenizer/index.html">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,8 +21,7 @@ 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.
SEARCH on <module@>threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include <module@>threads.jam ;
import ../build/threads ;
{
template example

View File

@@ -13,7 +13,7 @@
#define BOOST_THREAD_WEK01082003_HPP
#include <boost/thread/thread.hpp>
#include <boost/thread/conditin.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/once.hpp>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -13,9 +13,8 @@
#define BOOST_TSS_WEK070601_HPP
#include <boost/config.hpp>
#ifndef BOOST_HAS_THREADS
# error Thread support is unavailable!
#endif
// insist on threading support being available:
#include <boost/config/requires_threads.hpp>
#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 = CreateMutex(NULL, FALSE, strm.str());
HANDLE mutex = CreateMutexA(NULL, FALSE, strm.str());
#else
std::ostringstream strm;
strm << "2AC1A572DB6944B0A65C38C4140AF2F4" << std::hex
@@ -142,7 +142,18 @@ void call_once(void (*func)(), once_flag& flag)
if (compare_exchange(&flag, 1, 1) == 0)
{
func();
try
{
func();
}
catch (...)
{
res = ReleaseMutex(mutex);
assert(res);
res = CloseHandle(mutex);
assert(res);
throw;
}
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,12 +21,10 @@ 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.
SEARCH on threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include threads.jam ;
import ../build/threads ;
# bring in rules for testing
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
include testing.jam ;
import testing ;
{
template test

35
test/Jamfile.v2 Normal file
View File

@@ -0,0 +1,35 @@
# (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,6 +17,7 @@
#include "util.inl"
boost::mutex check_mutex;
boost::mutex tss_mutex;
int tss_instances = 0;
@@ -44,7 +45,13 @@ void test_tss_thread()
for (int i=0; i<1000; ++i)
{
int& n = tss_value->value;
BOOST_CHECK_EQUAL(n, i);
// 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);
}
++n;
}
}

View File

@@ -22,8 +22,7 @@ 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.
SEARCH on <module@>threads.jam = $(BOOST_ROOT)/libs/thread/build ;
include <module@>threads.jam ;
import ../build/threads ;
{
template tutorial