|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57574 - in sandbox/fiber: boost/fiber boost/fiber/detail libs/fiber/src libs/fiber/test
From: oliver.kowalke_at_[hidden]
Date: 2009-11-11 13:21:38
Author: olli
Date: 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
New Revision: 57574
URL: http://svn.boost.org/trac/boost/changeset/57574
Log:
- move op. of fiber
- namespace renamed boost::fiber -> boost::fibers
Added:
sandbox/fiber/boost/fiber/detail/move.hpp (contents, props changed)
Text files modified:
sandbox/fiber/boost/fiber/attributes.hpp | 8 +-
sandbox/fiber/boost/fiber/auto_reset_event.hpp | 8 +-
sandbox/fiber/boost/fiber/condition.hpp | 8 +-
sandbox/fiber/boost/fiber/count_down_event.hpp | 8 +-
sandbox/fiber/boost/fiber/detail/atomic_aix.hpp | 8 +-
sandbox/fiber/boost/fiber/detail/atomic_gcc.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_gcc_ppc.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_gcc_x86.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_hpux.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_interlocked.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_interprocess.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_solaris.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/atomic_sync.hpp | 9 +-
sandbox/fiber/boost/fiber/detail/config.hpp | 7 -
sandbox/fiber/boost/fiber/detail/fiber_info.hpp | 34 +++++---
sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp | 10 +-
sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp | 8 +-
sandbox/fiber/boost/fiber/detail/has_sync.hpp | 6
sandbox/fiber/boost/fiber/exceptions.hpp | 16 +++-
sandbox/fiber/boost/fiber/fiber.hpp | 150 ++++++++++++++++++++++++++++++++++++----
sandbox/fiber/boost/fiber/manual_reset_event.hpp | 8 +-
sandbox/fiber/boost/fiber/mutex.hpp | 8 +-
sandbox/fiber/boost/fiber/policy.hpp | 13 ++-
sandbox/fiber/boost/fiber/rrp.hpp | 8 +-
sandbox/fiber/boost/fiber/scheduler.hpp | 90 ++++++++++-------------
sandbox/fiber/boost/fiber/unique_lock.hpp | 8 +-
sandbox/fiber/boost/fiber/utility.hpp | 10 +-
sandbox/fiber/libs/fiber/src/attributes.cpp | 2
sandbox/fiber/libs/fiber/src/auto_reset_event.cpp | 2
sandbox/fiber/libs/fiber/src/condition.cpp | 2
sandbox/fiber/libs/fiber/src/count_down_event.cpp | 2
sandbox/fiber/libs/fiber/src/fiber.cpp | 94 ++++++++++++++++++++----
sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp | 12 +-
sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp | 2
sandbox/fiber/libs/fiber/src/fiber_posix.cpp | 25 +++++
sandbox/fiber/libs/fiber/src/manual_reset_event.cpp | 2
sandbox/fiber/libs/fiber/src/mutex.cpp | 8 +-
sandbox/fiber/libs/fiber/src/rrp.cpp | 8 +
sandbox/fiber/libs/fiber/src/scheduler.cpp | 31 ++++++-
sandbox/fiber/libs/fiber/test/test_auto_reset_event.cpp | 12 +-
sandbox/fiber/libs/fiber/test/test_condition.cpp | 28 +++---
sandbox/fiber/libs/fiber/test/test_count_down_event.cpp | 8 +-
sandbox/fiber/libs/fiber/test/test_fiber.cpp | 62 +++++++++++++--
sandbox/fiber/libs/fiber/test/test_generic_locks.cpp | 54 +++++++-------
sandbox/fiber/libs/fiber/test/test_manual_reset_event.cpp | 16 ++--
sandbox/fiber/libs/fiber/test/test_mutex.cpp | 18 ++--
sandbox/fiber/libs/fiber/test/test_rrp.cpp | 11 +-
sandbox/fiber/libs/fiber/test/test_unique_lock.cpp | 46 ++++++------
sandbox/fiber/libs/fiber/test/test_utility.cpp | 8 +-
49 files changed, 600 insertions(+), 341 deletions(-)
Modified: sandbox/fiber/boost/fiber/attributes.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/attributes.hpp (original)
+++ sandbox/fiber/boost/fiber/attributes.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_ATTRIBUTES_H
-#define BOOST_FIBER_ATTRIBUTES_H
+#ifndef BOOST_FIBERS_ATTRIBUTES_H
+#define BOOST_FIBERS_ATTRIBUTES_H
#include <cstddef>
@@ -14,7 +14,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class BOOST_FIBER_DECL attributes
{
@@ -38,4 +38,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_ATTRIBUTES_H
+#endif // BOOST_FIBERS_ATTRIBUTES_H
Modified: sandbox/fiber/boost/fiber/auto_reset_event.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/auto_reset_event.hpp (original)
+++ sandbox/fiber/boost/fiber/auto_reset_event.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,15 +4,15 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_AUTO_RESET_EVENT_H
-#define BOOST_FIBER_AUTO_RESET_EVENT_H
+#ifndef BOOST_FIBERS_AUTO_RESET_EVENT_H
+#define BOOST_FIBERS_AUTO_RESET_EVENT_H
#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class auto_reset_event : private noncopyable
{
@@ -43,4 +43,4 @@
}}
-#endif // BOOST_FIBER_AUTO_RESET_EVENT_H
+#endif // BOOST_FIBERS_AUTO_RESET_EVENT_H
Modified: sandbox/fiber/boost/fiber/condition.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/condition.hpp (original)
+++ sandbox/fiber/boost/fiber/condition.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -6,8 +6,8 @@
//
// based on boost::interprocess::sync::interprocess_condition
-#ifndef BOOST_FIBER_CONDITION_H
-#define BOOST_FIBER_CONDITION_H
+#ifndef BOOST_FIBERS_CONDITION_H
+#define BOOST_FIBERS_CONDITION_H
#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
@@ -17,7 +17,7 @@
#include <boost/fiber/mutex.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class condition : private noncopyable
{
@@ -119,4 +119,4 @@
}}
-#endif // BOOST_FIBER_CONDITION_H
+#endif // BOOST_FIBERS_CONDITION_H
Modified: sandbox/fiber/boost/fiber/count_down_event.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/count_down_event.hpp (original)
+++ sandbox/fiber/boost/fiber/count_down_event.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_COUNT_DOWN_EVENT_H
-#define BOOST_FIBER_COUNT_DOWN_EVENT_H
+#ifndef BOOST_FIBERS_COUNT_DOWN_EVENT_H
+#define BOOST_FIBERS_COUNT_DOWN_EVENT_H
#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
@@ -14,7 +14,7 @@
#include <boost/fiber/mutex.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class count_down_event : private noncopyable
{
@@ -44,4 +44,4 @@
}}
-#endif // BOOST_FIBER_COUNT_DOWN_EVENT_H
+#endif // BOOST_FIBERS_COUNT_DOWN_EVENT_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_aix.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_aix.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_aix.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_AIX_H
-#define BOOST_FIBER_DETAIL_ATOMIC_AIX_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_AIX_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_AIX_H
extern "C"
{
@@ -18,7 +18,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -51,5 +51,5 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_AIX_H
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_AIX_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_gcc.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_gcc.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_gcc.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_GCC_H
-#define BOOST_FIBER_DETAIL_ATOMIC_GCC_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_GCC_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_GCC_H
// based on boost/smart_ptr/detail/atomic_count_gcc.hpp
@@ -22,7 +22,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
#if defined(__GLIBCXX__) // g++ 3.4+
@@ -73,5 +73,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_GCC_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_GCC_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_gcc_ppc.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_gcc_ppc.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_gcc_ppc.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_GCC_PPC_H
-#define BOOST_FIBER_DETAIL_ATOMIC_GCC_PPC_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_GCC_PPC_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_GCC_PPC_H
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
@@ -13,7 +13,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -110,5 +110,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_GCC_PPC_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_GCC_PPC_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_gcc_x86.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_gcc_x86.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_gcc_x86.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_GCC_X86_H
-#define BOOST_FIBER_DETAIL_ATOMIC_GCC_X86_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_GCC_X86_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_GCC_X86_H
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
@@ -13,7 +13,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -87,5 +87,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_GCC_X86_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_GCC_X86_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_hpux.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_hpux.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_hpux.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_HPUX_H
-#define BOOST_FIBER_DETAIL_ATOMIC_HPUX_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_HPUX_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_HPUX_H
extern "C"
{
@@ -17,7 +17,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -58,5 +58,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_HPUX_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_HPUX_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_interlocked.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_interlocked.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_interlocked.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_INTERLOCKED_H
-#define BOOST_FIBER_DETAIL_ATOMIC_INTERLOCKED_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_INTERLOCKED_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_INTERLOCKED_H
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
@@ -14,7 +14,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -62,5 +62,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_INTERLOCKED_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_INTERLOCKED_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_interprocess.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_interprocess.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_interprocess.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_INTERPROCESS_H
-#define BOOST_FIBER_DETAIL_ATOMIC_INTERPROCESS_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_INTERPROCESS_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_INTERPROCESS_H
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
@@ -14,7 +14,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -55,5 +55,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_INTERPROCESS_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_INTERPROCESS_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_solaris.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_solaris.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_solaris.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_SOLARIS_H
-#define BOOST_FIBER_DETAIL_ATOMIC_SOLARIS_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_SOLARIS_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_SOLARIS_H
extern "C"
{
@@ -18,7 +18,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -59,5 +59,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_SOLARIS_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_SOLARIS_H
Modified: sandbox/fiber/boost/fiber/detail/atomic_sync.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/atomic_sync.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/atomic_sync.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_ATOMIC_SYNC_H
-#define BOOST_FIBER_DETAIL_ATOMIC_SYNC_H
+#ifndef BOOST_FIBERS_DETAIL_ATOMIC_SYNC_H
+#define BOOST_FIBERS_DETAIL_ATOMIC_SYNC_H
// based on boost/smart_ptr/detail/atomic_count_gc.hpp
@@ -22,7 +22,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
inline
@@ -63,5 +63,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_ATOMIC_SYNC_H
-
+#endif // BOOST_FIBERS_DETAIL_ATOMIC_SYNC_H
Modified: sandbox/fiber/boost/fiber/detail/config.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/config.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/config.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -6,8 +6,8 @@
// this file is based on config.hpp of boost.thread
-#ifndef BOOST_FIBER_DETAIL_CONFIG_H
-#define BOOST_FIBER_DETAIL_CONFIG_H
+#ifndef BOOST_FIBERS_DETAIL_CONFIG_H
+#define BOOST_FIBERS_DETAIL_CONFIG_H
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
@@ -86,5 +86,4 @@
#include <boost/config/auto_link.hpp>
# endif // auto-linking disabled
-#endif // BOOST_FIBER_DETAIL_CONFIG_H
-
+#endif // BOOST_FIBERS_DETAIL_CONFIG_H
Modified: sandbox/fiber/boost/fiber/detail/fiber_info.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/fiber_info.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,23 +4,16 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_FIBER_INFO_H
-#define BOOST_FIBER_DETAIL_FIBER_INFO_H
-
-extern "C" {
-
-#include <ucontext.h>
-
-}
+#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_H
+#define BOOST_FIBERS_DETAIL_FIBER_INFO_H
+#include <boost/assert.hpp>
#include <boost/config.hpp>
-#include <boost/function.hpp>
-#include <boost/shared_array.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/fiber/attributes.hpp>
#include <boost/fiber/detail/config.hpp>
+#include <boost/fiber/detail/move.hpp>
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#include <boost/fiber/detail/fiber_info_windows.hpp>
@@ -33,7 +26,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
class BOOST_FIBER_DECL fiber_info_default : public fiber_info_base
@@ -47,7 +40,8 @@
fiber_info_base()
{}
- void run() {}
+ void run()
+ { BOOST_ASSERT( ! "run() of master-fiber should never be executed"); }
};
template< typename Fn >
@@ -60,11 +54,23 @@
fiber_info & operator=( fiber_info const&);
public:
+#ifdef BOOST_HAS_RVALUE_REFS
+ thread_data( Fn && fn, attributes const& attribs) :
+ fiber_info_base( attribs),
+ fn_( static_cast< Fn && >( fn) )
+ {}
+#else
fiber_info( Fn fn, attributes const& attribs) :
fiber_info_base( attribs),
fn_( fn)
{}
+ fiber_info( boost::detail::fiber_move_t< Fn > fn, attributes const& attribs) :
+ fiber_info_base( attribs),
+ fn_( fn)
+ {}
+#endif
+
void run()
{ fn_(); }
};
@@ -111,4 +117,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_FIBER_INFO_H
+#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_H
Modified: sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_posix.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_FIBER_INFO_POSIX_H
-#define BOOST_FIBER_DETAIL_FIBER_INFO_POSIX_H
+#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
+#define BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
extern "C" {
@@ -24,7 +24,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
struct BOOST_FIBER_DECL fiber_info_base
@@ -32,7 +32,7 @@
typedef intrusive_ptr< fiber_info_base > ptr_t;
uint32_t use_count;
- attributes attribs;
+ attributes attrs;
::ucontext_t uctx;
shared_array< char > uctx_stack;
@@ -83,4 +83,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_FIBER_INFO_POSIX_H
+#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_POSIX_H
Modified: sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/fiber_info_windows.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_DETAIL_FIBER_INFO_WINDOWS_H
-#define BOOST_FIBER_DETAIL_FIBER_INFO_WINDOWS_H
+#ifndef BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
+#define BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
extern "C" {
@@ -25,7 +25,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
struct BOOST_FIBER_DECL fiber_info_base
@@ -83,4 +83,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_DETAIL_FIBER_INFO_WINDOWS_H
+#endif // BOOST_FIBERS_DETAIL_FIBER_INFO_WINDOWS_H
Modified: sandbox/fiber/boost/fiber/detail/has_sync.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/has_sync.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/has_sync.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -1,5 +1,5 @@
-#ifndef BOOST_FIBER_DETAIL_HAS_SYNC_H
-#define BOOST_FIBER_DETAIL_HAS_SYNC_H
+#ifndef BOOST_FIBERS_DETAIL_HAS_SYNC_H
+#define BOOST_FIBERS_DETAIL_HAS_SYNC_H
// MS compatible compilers support #pragma once
@@ -46,4 +46,4 @@
#endif // __GNUC__ * 100 + __GNUC_MINOR__ >= 401
-#endif // BOOST_FIBER_DETAIL_HAS_SYNC_H
+#endif // BOOST_FIBERS_DETAIL_HAS_SYNC_H
Added: sandbox/fiber/boost/fiber/detail/move.hpp
==============================================================================
--- (empty file)
+++ sandbox/fiber/boost/fiber/detail/move.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -0,0 +1,56 @@
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// (C) Copyright 2007-8 Anthony Williams
+
+#ifndef BOOST_FIBERS_DETAIL_MOVE_HPP
+#define BOOST_FIBERS_DETAIL_MOVE_HPP
+
+#include <boost/config.hpp>
+
+#ifndef BOOST_NO_SFINAE
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#endif
+
+#include <boost/config/abi_prefix.hpp>
+
+namespace boost {
+namespace detail {
+
+template< typename F >
+struct fiber_move_t
+{
+ F & f;
+
+ explicit fiber_move_t( F & f_) :
+ f( f_)
+ {}
+
+ F & operator*() const
+ { return f; }
+
+ F * operator->() const
+ { return & f; }
+
+private:
+ void operator=( fiber_move_t &);
+};
+
+}
+
+#ifndef BOOST_NO_SFINAE
+template< typename F >
+typename enable_if< is_convertible< F &, detail::fiber_move_t< F > >, F >::type move( F & f)
+{ return F( detail::fiber_move_t< F >( f) ); }
+#endif
+
+template< typename F >
+detail::fiber_move_t< F > move( detail::fiber_move_t< F > f)
+{ return f; }
+
+}
+
+#include <boost/config/abi_suffix.hpp>
+
+#endif // BOOST_FIBERS_DETAIL_MOVE_H
Modified: sandbox/fiber/boost/fiber/exceptions.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/exceptions.hpp (original)
+++ sandbox/fiber/boost/fiber/exceptions.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_EXCEPTIONS_H
-#define BOOST_FIBER_EXCEPTIONS_H
+#ifndef BOOST_FIBERS_EXCEPTIONS_H
+#define BOOST_FIBERS_EXCEPTIONS_H
#include <stdexcept>
#include <string>
@@ -15,7 +15,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class fiber_error : public std::runtime_error
{
@@ -28,6 +28,14 @@
class fiber_interrupted
{};
+class fiber_moved : public std::logic_error
+{
+public:
+ fiber_moved() :
+ std::logic_error("fiber moved")
+ {}
+};
+
class invalid_stacksize : public std::runtime_error
{
public:
@@ -56,4 +64,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_EXCEPTIONS_H
+#endif // BOOST_FIBERS_EXCEPTIONS_H
Modified: sandbox/fiber/boost/fiber/fiber.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/fiber.hpp (original)
+++ sandbox/fiber/boost/fiber/fiber.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,40 +4,72 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_FIBER_H
-#define BOOST_FIBER_FIBER_H
+#ifndef BOOST_FIBERS_FIBER_H
+#define BOOST_FIBERS_FIBER_H
#include <iostream>
#include <boost/bind.hpp>
+#include <boost/config.hpp>
#include <boost/preprocessor/repetition.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/utility.hpp>
#include <boost/fiber/attributes.hpp>
#include <boost/fiber/detail/config.hpp>
#include <boost/fiber/detail/fiber_info.hpp>
+#include <boost/fiber/detail/move.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
-class fiber;
-void trampoline( fiber * fib);
+class rrp;
-class BOOST_FIBER_DECL fiber : private noncopyable
+class BOOST_FIBER_DECL fiber
{
private:
- friend void trampoline( fiber *);
+ friend class rrp;
+
+ struct dummy;
detail::fiber_info_base::ptr_t info_;
+ explicit fiber( detail::fiber_info_base::ptr_t);
+
fiber( fiber &);
- fiber & operator=( fiber const&);
+ fiber & operator=( fiber &);
void init_();
- struct dummy;
+#ifdef BOOST_HAS_RVALUE_REFS
+ template< typename Fn >
+ static detail::fiber_info_base::ptr_t make_info_( Fn && fn)
+ {
+ return detail::fiber_info_base::ptr_t(
+ new detail::fiber_info< typename remove_reference< Fn >::type >(
+ static_cast< Fn && >( fn), attributes() ) );
+ }
+
+ static detail::fiber_info_base::ptr_t make_info_( void ( * fn)() );
+#else
+ template< typename Fn >
+ static detail::fiber_info_base::ptr_t make_info_( Fn fn)
+ {
+ return detail::fiber_info_base::ptr_t(
+ new detail::fiber_info< Fn >( fn, attributes() ) );
+ }
+
+ template< typename Fn >
+ static detail::fiber_info_base::ptr_t make_info_(
+ boost::detail::fiber_move_t< Fn > fn)
+ {
+ return detail::fiber_info_base::ptr_t(
+ new detail::fiber_info< Fn >( fn, attributes() ) );
+ }
+#endif
public:
class id;
@@ -46,15 +78,78 @@
fiber();
+#ifdef BOOST_HAS_RVALUE_REFS
+ template< typename Fn >
+ fiber( Fn && fn) :
+ info_( make_info_( static_cast< Fn && >( fn) ) )
+ { init_(); }
+
+ fiber( fiber &&);
+
+ fiber & operator=( fiber &&);
+
+ fiber && move();
+#else
+#ifdef BOOST_NO_SFINAE
+ template< typename Fn >
+ explicit fiber( Fn fn) :
+ info_( make_info_( fn) )
+ { init_(); }
+#else
+ template< typename Fn >
+ explicit fiber(
+ Fn fn,
+ typename disable_if< boost::is_convertible< Fn &, boost::detail::fiber_move_t< Fn > >, dummy * >::type = 0) :
+ info_( make_info_( fn) )
+ { init_(); }
+#endif
template< typename Fn >
- explicit fiber( Fn fn, attributes const& attrs) :
- info_( new detail::fiber_info< Fn >( fn, attrs) )
+ explicit fiber( boost::detail::fiber_move_t< Fn > fn) :
+ info_( make_info_( fn) )
{ init_(); }
+ fiber( boost::detail::fiber_move_t< fiber >);
+
+ fiber & operator=( boost::detail::fiber_move_t< fiber >);
+
+ operator boost::detail::fiber_move_t< fiber >();
+
+ boost::detail::fiber_move_t< fiber > move();
+#endif
+
+#define BOOST_FIBER_ARG(z, n, unused) \
+ BOOST_PP_CAT(A, n) BOOST_PP_CAT(a, n)
+#define BOOST_ENUM_FIBER_ARGS(n) BOOST_PP_ENUM(n, BOOST_FIBER_ARG, ~)
+
+#define BOOST_FIBER_FIBER_CTOR(z, n, unused) \
+ template< typename Fn, BOOST_PP_ENUM_PARAMS(n, typename A) > \
+ fiber( Fn fn, BOOST_ENUM_FIBER_ARGS(n)) : \
+ info_( \
+ make_info_( \
+ boost::bind( boost::type< void >(), fn, BOOST_PP_ENUM_PARAMS(n, a)) ) ) \
+ { init_(); } \
+
+#ifndef BOOST_FIBER_MAX_ARITY
+#define BOOST_FIBER_MAX_ARITY 10
+#endif
+
+BOOST_PP_REPEAT_FROM_TO( 1, BOOST_FIBER_MAX_ARITY, BOOST_FIBER_FIBER_CTOR, ~)
+
+#undef BOOST_FIBER_FIBER_CTOR
+
+ typedef detail::fiber_info_base::ptr_t::unspecified_bool_type unspecified_bool_type;
+
+ operator unspecified_bool_type() const;
+
+ bool operator!() const;
+
void swap( fiber & other);
id get_id() const;
+ attributes const& get_attributes() const;
+ void set_attributes( attributes const&);
+
bool operator==( fiber const& other) const;
bool operator!=( fiber const& other) const;
@@ -106,17 +201,42 @@
}
};
-void trampoline( fiber *);
+template< typename Fn >
+fiber make_fiber( Fn fn)
+{ return fiber( fn); }
+
+#define BOOST_FIBER_make_info_FUNCTION(z, n, unused) \
+template< typename Fn, BOOST_PP_ENUM_PARAMS(n, typename A) > \
+fiber make_fiber( Fn fn, BOOST_ENUM_FIBER_ARGS(n)) \
+{ return fiber( fn, BOOST_PP_ENUM_PARAMS(n, a) ); } \
+
+BOOST_PP_REPEAT_FROM_TO( 1, BOOST_FIBER_MAX_ARITY, BOOST_FIBER_make_info_FUNCTION, ~)
+
+#undef BOOST_FIBER_make_info_FUNCTION
+#undef BOOST_ENUM_FIBER_ARGS
+#undef BOOST_FIBER_ARG
+#undef BOOST_FIBER_MAX_ARITY
}
+using fibers::fiber;
+
inline
-void swap( fiber::fiber & lhs, fiber::fiber & rhs)
+void swap( fiber & lhs, fiber & rhs)
{ return lhs.swap( rhs); }
+#ifdef BOOST_HAS_RVALUE_REFS
+inline
+fiber && move( fiber && f)
+{ return f; }
+#else
+inline
+fiber move( boost::detail::fiber_move_t< fiber > f)
+{ return fiber( f); }
+#endif
+
}
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_FIBER_H
-
+#endif // BOOST_FIBERS_FIBER_H
Modified: sandbox/fiber/boost/fiber/manual_reset_event.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/manual_reset_event.hpp (original)
+++ sandbox/fiber/boost/fiber/manual_reset_event.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBEr_MANUAL_RESET_EVENT_H
-#define BOOST_FIBEr_MANUAL_RESET_EVENT_H
+#ifndef BOOST_FIBERS_MANUAL_RESET_EVENT_H
+#define BOOST_FIBERS_MANUAL_RESET_EVENT_H
#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
@@ -14,7 +14,7 @@
#include <boost/fiber/mutex.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class manual_reset_event : private noncopyable
{
@@ -49,4 +49,4 @@
}}
-#endif // BOOST_FIBER_MANUAL_RESET_EVENT_H
+#endif // BOOST_FIBERS_MANUAL_RESET_EVENT_H
Modified: sandbox/fiber/boost/fiber/mutex.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/mutex.hpp (original)
+++ sandbox/fiber/boost/fiber/mutex.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -6,8 +6,8 @@
//
// based on boost::interprocess::sync::interprocess_mutex
-#ifndef BOOST_FIBER_MUTEX_H
-#define BOOST_FIBER_MUTEX_H
+#ifndef BOOST_FIBERS_MUTEX_H
+#define BOOST_FIBERS_MUTEX_H
#include <boost/cstdint.hpp>
#include <boost/thread/thread_time.hpp>
@@ -16,7 +16,7 @@
#include <boost/fiber/unique_lock.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class mutex : private noncopyable
{
@@ -45,4 +45,4 @@
}}
-#endif // BOOST_FIBER_MUTEX_H
+#endif // BOOST_FIBERS_MUTEX_H
Modified: sandbox/fiber/boost/fiber/policy.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/policy.hpp (original)
+++ sandbox/fiber/boost/fiber/policy.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_POLICY_H
-#define BOOST_FIBER_POLICY_H
+#ifndef BOOST_FIBERS_POLICY_H
+#define BOOST_FIBERS_POLICY_H
#include <cstddef>
#include <memory>
@@ -15,7 +15,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
struct policy
{
@@ -36,8 +36,13 @@
virtual std::size_t size() = 0;
};
+enum policy_t
+{
+ round_robin_policy = 0
+};
+
}}
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_POLICY_H
+#endif // BOOST_FIBERS_POLICY_H
Modified: sandbox/fiber/boost/fiber/rrp.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/rrp.hpp (original)
+++ sandbox/fiber/boost/fiber/rrp.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_RRP_H
-#define BOOST_FIBER_RRP_H
+#ifndef BOOST_FIBERS_RRP_H
+#define BOOST_FIBERS_RRP_H
#include <cstddef>
#include <memory>
@@ -21,7 +21,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
class BOOST_FIBER_DECL rrp : private noncopyable,
public policy
@@ -55,4 +55,4 @@
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_RRP_H
+#endif // BOOST_FIBERS_RRP_H
Modified: sandbox/fiber/boost/fiber/scheduler.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/scheduler.hpp (original)
+++ sandbox/fiber/boost/fiber/scheduler.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,8 +4,8 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_FIBER_SCHEDULER_H
-#define BOOST_FIBER_SCHEDULER_H
+#ifndef BOOST_FIBERS_SCHEDULER_H
+#define BOOST_FIBERS_SCHEDULER_H
#include <cstddef>
#include <memory>
@@ -33,12 +33,11 @@
}
-namespace fiber {
+namespace fibers {
class BOOST_FIBER_DECL scheduler : private noncopyable
{
private:
- friend void trampoline( fiber *);
friend bool this_fiber::runs_as_fiber();
friend fiber::id this_fiber::get_id();
friend void this_fiber::yield();
@@ -52,32 +51,43 @@
static fiber::id get_id();
- static void yield();
+ static void fiber_yield();
- static void exit();
+ static void fiber_exit();
- static void failed();
+ static void fiber_failed();
+
+ policy_t pol_;
policy * access_();
public:
+ scheduler( policy_t = round_robin_policy);
+
~scheduler();
+ bool run();
+
+ bool empty();
+
+ std::size_t size();
+
+ void submit_fiber( fiber);
+
template< typename Fn >
void make_fiber( Fn fn)
{
- attributes attrs;
access_()->add_fiber(
std::auto_ptr< fiber >(
- new fiber( fn, attrs) ) );
+ new fiber( fn) ) );
}
template< typename Fn >
void make_fiber( attributes attrs, Fn fn)
{
- access_()->add_fiber(
- std::auto_ptr< fiber >(
- new fiber( fn, attrs) ) );
+ std::auto_ptr< fiber > f( new fiber( fn) );
+ f->set_attributes( attrs);
+ access_()->add_fiber( f);
}
#ifndef BOOST_FIBER_MAX_ARITY
@@ -88,55 +98,31 @@
BOOST_PP_CAT(A, n) BOOST_PP_CAT(a, n)
#define BOOST_ENUM_FIBER_ARGS(n) BOOST_PP_ENUM(n, BOOST_FIBER_ARG, ~)
-#define BOOST_FIBER_MAKE_FIBER_FUNCTION(z, n, unused) \
- template< \
- typename Fn, \
- BOOST_PP_ENUM_PARAMS(n, typename A) \
- > \
- void make_fiber( Fn fn, BOOST_ENUM_FIBER_ARGS(n)) \
- { \
- attributes attrs; \
- access_()->add_fiber( \
- std::auto_ptr< fiber >( \
- new fiber( \
- boost::bind( \
- boost::type< void >(), fn, BOOST_PP_ENUM_PARAMS(n, a) ),\
- attrs) ) ); \
- }
-
-BOOST_PP_REPEAT_FROM_TO( 1, BOOST_FIBER_MAX_ARITY, BOOST_FIBER_MAKE_FIBER_FUNCTION, ~)
-
-#undef BOOST_FIBER_MAKE_FIBER_FUNCTION
-
-#define BOOST_FIBER_MAKE_FIBER_FUNCTION(z, n, unused) \
- template< \
- typename Fn, \
- BOOST_PP_ENUM_PARAMS(n, typename A) \
- > \
- void make_fiber( attributes const& attrs, Fn fn, BOOST_ENUM_FIBER_ARGS(n)) \
- { \
- access_()->add_fiber( \
- std::auto_ptr< fiber >( \
- new fiber( \
- boost::bind( \
- boost::type< void >(), fn, BOOST_PP_ENUM_PARAMS(n, a) ),\
- attrs) ) ); \
+#define BOOST_FIBER_MAKE_FIBER_FUNCTION(z, n, unused) \
+ template< typename Fn, BOOST_PP_ENUM_PARAMS(n, typename A) > \
+ void make_fiber( Fn fn, BOOST_ENUM_FIBER_ARGS(n)) \
+ { \
+ access_()->add_fiber( \
+ std::auto_ptr< fiber >( \
+ new fiber( fn, BOOST_PP_ENUM_PARAMS(n, a) ) ) ); \
+ } \
+ template< typename Fn, BOOST_PP_ENUM_PARAMS(n, typename A) > \
+ void make_fiber( attributes const& attrs, Fn fn, BOOST_ENUM_FIBER_ARGS(n)) \
+ { \
+ std::auto_ptr< fiber > f( \
+ new fiber( fn, BOOST_PP_ENUM_PARAMS(n, a) ) ); \
+ f->set_attributes( attrs); \
+ access_()->add_fiber( f);\
}
BOOST_PP_REPEAT_FROM_TO( 1, BOOST_FIBER_MAX_ARITY, BOOST_FIBER_MAKE_FIBER_FUNCTION, ~)
#undef BOOST_FIBER_MAKE_FIBER_FUNCTION
#undef BOOST_FIBER_MAX_ARITY
-
- bool run();
-
- bool empty();
-
- std::size_t size();
};
}}
#include <boost/config/abi_suffix.hpp>
-#endif // BOOST_FIBER_SCHEDULER_H
+#endif // BOOST_FIBERS_SCHEDULER_H
Modified: sandbox/fiber/boost/fiber/unique_lock.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/unique_lock.hpp (original)
+++ sandbox/fiber/boost/fiber/unique_lock.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -6,8 +6,8 @@
//
// based on boost::interprocess::sync::scoped_lock
-#ifndef BOOST_FIBER_UNIQUE_LOCK_H
-#define BOOST_FIBER_UNIQUE_LOCK_H
+#ifndef BOOST_FIBERS_UNIQUE_LOCK_H
+#define BOOST_FIBERS_UNIQUE_LOCK_H
#include <algorithm>
@@ -17,7 +17,7 @@
#include <boost/fiber/exceptions.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
template< typename Mutex >
class unique_lock
@@ -144,4 +144,4 @@
}}
-#endif // BOOST_FIBER_UNIQUE_LOCK_H
+#endif // BOOST_FIBERS_UNIQUE_LOCK_H
Modified: sandbox/fiber/boost/fiber/utility.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/utility.hpp (original)
+++ sandbox/fiber/boost/fiber/utility.hpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -21,19 +21,19 @@
inline
bool runs_as_fiber()
-{ return fiber::scheduler::runs_as_fiber(); }
+{ return fibers::scheduler::runs_as_fiber(); }
inline
-fiber::fiber::id get_id()
-{ return fiber::scheduler::get_id(); }
+fiber::id get_id()
+{ return fibers::scheduler::get_id(); }
inline
void yield()
-{ fiber::scheduler::yield(); }
+{ fibers::scheduler::fiber_yield(); }
inline
void cancel()
-{ fiber::scheduler::exit(); }
+{ fibers::scheduler::fiber_exit(); }
}}
Modified: sandbox/fiber/libs/fiber/src/attributes.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/attributes.cpp (original)
+++ sandbox/fiber/libs/fiber/src/attributes.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -11,7 +11,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
attributes::attributes() :
stacksize_( 64000),
Modified: sandbox/fiber/libs/fiber/src/auto_reset_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/auto_reset_event.cpp (original)
+++ sandbox/fiber/libs/fiber/src/auto_reset_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -10,7 +10,7 @@
#include <boost/fiber/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
auto_reset_event::auto_reset_event( bool isset) :
state_(
Modified: sandbox/fiber/libs/fiber/src/condition.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/condition.cpp (original)
+++ sandbox/fiber/libs/fiber/src/condition.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -14,7 +14,7 @@
#include <boost/fiber/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
void
condition::notify_( uint32_t cmd)
Modified: sandbox/fiber/libs/fiber/src/count_down_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/count_down_event.cpp (original)
+++ sandbox/fiber/libs/fiber/src/count_down_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -11,7 +11,7 @@
#include <boost/fiber/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
count_down_event::count_down_event( uint32_t initial) :
initial_( initial),
Modified: sandbox/fiber/libs/fiber/src/fiber.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -9,21 +9,80 @@
#include <boost/assert.hpp>
#include <boost/fiber/exceptions.hpp>
-#include <boost/fiber/scheduler.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
void
fiber::convert_thread_to_fiber()
{ detail::fiber_info_base::convert_thread_to_fiber(); }
+#ifdef BOOST_HAS_RVALUE_REFS
+detail::fiber_info_base::ptr_t
+fiber::make_info_( void ( * fn)() )
+{
+ return detail::fiber_info_base::ptr_t(
+ new detail::fiber_info< void( *)() >( fn, attributes() ) );
+}
+#endif
+
fiber::fiber() :
- info_( new detail::fiber_info_default() )
+ info_()
+{}
+
+fiber::fiber( detail::fiber_info_base::ptr_t info) :
+ info_( info)
{}
+#ifdef BOOST_HAS_RVALUE_REFS
+fiber::fiber( fiber && other)
+{ info_.swap( other.info_); }
+
+fiber &
+fiber::operator=( fiber && other)
+{
+ info_ = other.info_;
+ other.info_.reset();
+ return * this;
+}
+
+fiber &&
+fiber::move()
+{ return static_cast< fiber && >( * this); }
+#else
+fiber::fiber( boost::detail::fiber_move_t< fiber > f)
+{
+ info_ = f->info_;
+ f->info_.reset();
+}
+
+fiber &
+fiber::operator=( boost::detail::fiber_move_t< fiber > f)
+{
+ fiber new_fiber( f);
+ swap( new_fiber);
+ return * this;
+}
+
+fiber::operator boost::detail::fiber_move_t< fiber >()
+{ return move(); }
+
+boost::detail::fiber_move_t< fiber >
+fiber::move()
+{
+ boost::detail::fiber_move_t< fiber > f( * this);
+ return f;
+}
+#endif
+fiber::operator unspecified_bool_type() const
+{ return info_; }
+
+bool
+fiber::operator!() const
+{ return ! info_; }
+
void
fiber::swap( fiber & other)
{ info_.swap( other.info_); }
@@ -32,6 +91,20 @@
fiber::get_id() const
{ return fiber::id( info_); }
+attributes const&
+fiber::get_attributes() const
+{
+ if ( ! info_) throw fiber_moved();
+ return info_->attrs;
+}
+
+void
+fiber::set_attributes( attributes const& attrs)
+{
+ if ( ! info_) throw fiber_moved();
+ info_->attrs = attrs;
+}
+
bool
fiber::operator==( fiber const& other) const
{ return get_id() == other.get_id(); }
@@ -40,21 +113,6 @@
fiber::operator!=( fiber const& other) const
{ return !( get_id() == other.get_id() ); }
-void trampoline( fiber * self)
-{
- BOOST_ASSERT( self);
- BOOST_ASSERT( self->info_);
- try
- {
- self->info_->run();
- scheduler::exit();
- }
- catch ( fiber_interrupted const&)
- { scheduler::failed(); }
- catch (...)
- { scheduler::failed(); }
-}
-
}}
#include <boost/config/abi_suffix.hpp>
Modified: sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber_info_posix.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -14,19 +14,19 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
fiber_info_base::fiber_info_base() :
- attribs(),
+ attrs(),
uctx(),
uctx_stack()
{}
-fiber_info_base::fiber_info_base( attributes const& attribs_) :
- attribs( attribs_),
+fiber_info_base::fiber_info_base( attributes const& attrs_) :
+ attrs( attrs_),
uctx(),
- uctx_stack( new char[attribs.stack_size()])
+ uctx_stack( new char[attrs.stack_size()])
{
BOOST_ASSERT( uctx_stack);
@@ -36,7 +36,7 @@
errno,
system::system_category) );
uctx.uc_stack.ss_sp = uctx_stack.get();
- uctx.uc_stack.ss_size = attribs.stack_size();
+ uctx.uc_stack.ss_size = attrs.stack_size();
uctx.uc_link = 0;
}
Modified: sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber_info_windows.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -14,7 +14,7 @@
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
namespace detail {
fiber_info_base::fiber_info_base() :
Modified: sandbox/fiber/libs/fiber/src/fiber_posix.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/fiber_posix.cpp (original)
+++ sandbox/fiber/libs/fiber/src/fiber_posix.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -14,30 +14,49 @@
#include <cerrno>
+#include <boost/fiber/exceptions.hpp>
+#include <boost/fiber/utility.hpp>
+
#include <boost/system/system_error.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
+
+void trampoline( detail::fiber_info_base * self)
+{
+ BOOST_ASSERT( self);
+ try
+ { self->run(); }
+ catch ( fiber_interrupted const&)
+ {}
+ catch (...)
+ {}
+ this_fiber::cancel();
+}
void
fiber::init_()
{
- typedef void fn_type( fiber *);
+ typedef void fn_type( detail::fiber_info_base *);
typedef void ( * st_fn)();
fn_type * fn_ptr( trampoline);
+ if ( ! info_) throw fiber_moved();
+
::makecontext(
& info_->uctx,
( st_fn)( fn_ptr),
1,
- this);
+ info_.get() );
}
void
fiber::switch_to( fiber & to)
{
+ if ( ! info_) throw fiber_moved();
+
if ( ::swapcontext( & info_->uctx, & to.info_->uctx) != 0)
throw system::system_error(
system::error_code(
Modified: sandbox/fiber/libs/fiber/src/manual_reset_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/manual_reset_event.cpp (original)
+++ sandbox/fiber/libs/fiber/src/manual_reset_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -12,7 +12,7 @@
#include <boost/fiber/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
manual_reset_event::manual_reset_event( bool isset) :
state_(
Modified: sandbox/fiber/libs/fiber/src/mutex.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/mutex.cpp (original)
+++ sandbox/fiber/libs/fiber/src/mutex.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -4,13 +4,13 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include "boost/fiber/mutex.hpp"
+#include <boost/fiber/mutex.hpp>
-#include "boost/fiber/detail/atomic.hpp"
-#include "boost/fiber/utility.hpp"
+#include <boost/fiber/detail/atomic.hpp>
+#include <boost/fiber/utility.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
mutex::mutex() :
state_( 0)
Modified: sandbox/fiber/libs/fiber/src/rrp.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/rrp.cpp (original)
+++ sandbox/fiber/libs/fiber/src/rrp.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -8,15 +8,19 @@
#include <utility>
+#include <boost/fiber/detail/fiber_info.hpp>
+#include <boost/fiber/detail/move.hpp>
#include <boost/fiber/exceptions.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
rrp::rrp() :
- master_(),
+ master_(
+ detail::fiber_info_base::ptr_t(
+ new detail::fiber_info_default() ) ),
f_id_(),
fibers_(),
runnable_fibers_(),
Modified: sandbox/fiber/libs/fiber/src/scheduler.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/scheduler.cpp (original)
+++ sandbox/fiber/libs/fiber/src/scheduler.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -6,13 +6,14 @@
#include <boost/fiber/scheduler.hpp>
+#include <boost/fiber/detail/move.hpp>
#include <boost/fiber/exceptions.hpp>
#include <boost/fiber/rrp.hpp>
#include <boost/config/abi_prefix.hpp>
namespace boost {
-namespace fiber {
+namespace fibers {
scheduler::tss_policy_t scheduler::impl_;
@@ -29,7 +30,7 @@
}
void
-scheduler::yield()
+scheduler::fiber_yield()
{
policy * impl( impl_.get() );
if ( ! impl) throw fiber_error("not a fiber");
@@ -37,7 +38,7 @@
}
void
-scheduler::exit()
+scheduler::fiber_exit()
{
policy * impl( impl_.get() );
if ( ! impl) throw fiber_error("not a fiber");
@@ -45,20 +46,31 @@
}
void
-scheduler::failed()
+scheduler::fiber_failed()
{
policy * impl( impl_.get() );
if ( ! impl) throw fiber_error("not a fiber");
impl->exit_active_fiber();
}
+scheduler::scheduler( policy_t pol) :
+ pol_( pol)
+{}
+
policy *
scheduler::access_()
{
if ( ! impl_.get() )
{
fiber::convert_thread_to_fiber();
- impl_.reset( new rrp() );
+ switch ( pol_)
+ {
+ case round_robin_policy:
+ impl_.reset( new rrp() );
+ break;
+ default:
+ throw scheduler_error("invalid scheduling policy");
+ }
}
return impl_.get();
}
@@ -78,6 +90,15 @@
scheduler::size()
{ return access_()->size(); }
+void
+scheduler::submit_fiber( fiber f)
+{
+ access_()->add_fiber(
+ std::auto_ptr< fiber >(
+ new fiber(
+ boost::move( f) ) ) );
+}
+
}}
#include <boost/config/abi_suffix.hpp>
Modified: sandbox/fiber/libs/fiber/test/test_auto_reset_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_auto_reset_event.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_auto_reset_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -22,7 +22,7 @@
int value = 0;
-void wait_fn( boost::fiber::auto_reset_event & ev)
+void wait_fn( boost::fibers::auto_reset_event & ev)
{
ev.wait();
++value;
@@ -32,8 +32,8 @@
void test_case_1()
{
value = 0;
- boost::fiber::auto_reset_event ev;
- boost::fiber::scheduler sched;
+ boost::fibers::auto_reset_event ev;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -70,8 +70,8 @@
void test_case_2()
{
value = 0;
- boost::fiber::auto_reset_event ev( true);
- boost::fiber::scheduler sched;
+ boost::fibers::auto_reset_event ev( true);
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -101,7 +101,7 @@
void test_case_3()
{
- boost::fiber::auto_reset_event ev;
+ boost::fibers::auto_reset_event ev;
BOOST_CHECK_EQUAL( false, ev.try_wait() );
Modified: sandbox/fiber/libs/fiber/test/test_condition.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_condition.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_condition.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -22,21 +22,21 @@
int value = 0;
-void notify_one_fn( boost::fiber::condition & cond)
+void notify_one_fn( boost::fibers::condition & cond)
{
cond.notify_one();
}
-void notify_all_fn( boost::fiber::condition & cond)
+void notify_all_fn( boost::fibers::condition & cond)
{
cond.notify_all();
}
void wait_fn(
- boost::fiber::mutex & mtx,
- boost::fiber::condition & cond)
+ boost::fibers::mutex & mtx,
+ boost::fibers::condition & cond)
{
- boost::fiber::mutex::scoped_lock lk( mtx);
+ boost::fibers::mutex::scoped_lock lk( mtx);
cond.wait( lk);
++value;
}
@@ -44,9 +44,9 @@
void test_case_1()
{
value = 0;
- boost::fiber::mutex mtx;
- boost::fiber::condition cond;
- boost::fiber::scheduler sched;
+ boost::fibers::mutex mtx;
+ boost::fibers::condition cond;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -85,9 +85,9 @@
void test_case_2()
{
value = 0;
- boost::fiber::mutex mtx;
- boost::fiber::condition cond;
- boost::fiber::scheduler sched;
+ boost::fibers::mutex mtx;
+ boost::fibers::condition cond;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -139,9 +139,9 @@
void test_case_3()
{
value = 0;
- boost::fiber::mutex mtx;
- boost::fiber::condition cond;
- boost::fiber::scheduler sched;
+ boost::fibers::mutex mtx;
+ boost::fibers::condition cond;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
Modified: sandbox/fiber/libs/fiber/test/test_count_down_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_count_down_event.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_count_down_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -21,7 +21,7 @@
int value = 0;
-void wait_fn( boost::fiber::count_down_event & ev)
+void wait_fn( boost::fibers::count_down_event & ev)
{
ev.wait();
++value;
@@ -30,7 +30,7 @@
void test_case_1()
{
boost::uint32_t n = 3;
- boost::fiber::count_down_event ev( n);
+ boost::fibers::count_down_event ev( n);
BOOST_CHECK_EQUAL( ev.initial(), n);
BOOST_CHECK_EQUAL( ev.current(), n);
@@ -56,8 +56,8 @@
{
value = 0;
boost::uint32_t n = 3;
- boost::fiber::count_down_event ev( n);
- boost::fiber::scheduler sched;
+ boost::fibers::count_down_event ev( n);
+ boost::fibers::scheduler sched;
BOOST_CHECK_EQUAL( ev.initial(), n);
BOOST_CHECK_EQUAL( ev.current(), n);
Modified: sandbox/fiber/libs/fiber/test/test_fiber.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_fiber.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_fiber.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -14,35 +14,72 @@
void zero_args_fn() {}
-// check fiber
+void one_args_fn( int i) {}
+
+void two_args_fn( int i, std::string const& msg) {}
+
void test_case_1()
{
- boost::fiber::attributes attribs;
- boost::fiber::fiber f1( zero_args_fn, attribs);
- boost::fiber::fiber f2( zero_args_fn, attribs);
+ boost::fiber f1( one_args_fn, 10);
+ boost::fiber f2;
+ BOOST_CHECK( f1);
+ BOOST_CHECK( ! f2);
+}
+
+void test_case_2()
+{
+ boost::fiber f1;
+ f1 = boost::fibers::make_fiber( zero_args_fn);
+ boost::fiber f2 = boost::fibers::make_fiber( one_args_fn, 1);
+ boost::fiber f3;
+ f3 = boost::fibers::make_fiber( two_args_fn, 1, "abc");
+}
+
+void test_case_3()
+{
+ boost::fiber f1( one_args_fn, 10);
+ BOOST_CHECK( f1);
+ boost::fiber f2( boost::move( f1) );
+ BOOST_CHECK( ! f1);
+ BOOST_CHECK( f2);
+}
+
+void test_case_4()
+{
+ boost::fiber f1( zero_args_fn);
+ boost::fiber f2( zero_args_fn);
+ boost::fiber f3;
+ BOOST_CHECK( f1);
+ BOOST_CHECK( f2);
+ BOOST_CHECK( ! f3);
BOOST_CHECK( f1 != f2);
+ BOOST_CHECK( f1 != f3);
+ BOOST_CHECK( f2 != f3);
std::ostringstream os1;
os1 << f1.get_id();
std::ostringstream os2;
os2 << f2.get_id();
+ std::ostringstream os3;
+ os3 << f3.get_id();
std::string not_a_fiber("{not-a-fiber}");
BOOST_CHECK( os1.str() != os2.str() );
+ BOOST_CHECK( os1.str() != os3.str() );
+ BOOST_CHECK( os2.str() != os3.str() );
BOOST_CHECK( os1.str() != not_a_fiber);
BOOST_CHECK( os2.str() != not_a_fiber);
+ BOOST_CHECK( os3.str() == not_a_fiber);
}
-// check swap
-void test_case_2()
+void test_case_5()
{
- boost::fiber::attributes attribs;
- boost::fiber::fiber f1( zero_args_fn, attribs);
- boost::fiber::fiber f2( zero_args_fn, attribs);
+ boost::fiber f1( zero_args_fn);
+ boost::fiber f2( zero_args_fn);
- boost::fiber::fiber::id id1 = f1.get_id();
- boost::fiber::fiber::id id2 = f2.get_id();
+ boost::fiber::id id1 = f1.get_id();
+ boost::fiber::id id2 = f2.get_id();
f1.swap( f2);
@@ -57,6 +94,9 @@
test->add( BOOST_TEST_CASE( & test_case_1) );
test->add( BOOST_TEST_CASE( & test_case_2) );
+ test->add( BOOST_TEST_CASE( & test_case_3) );
+ test->add( BOOST_TEST_CASE( & test_case_4) );
+ test->add( BOOST_TEST_CASE( & test_case_5) );
return test;
}
Modified: sandbox/fiber/libs/fiber/test/test_generic_locks.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_generic_locks.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_generic_locks.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -12,9 +12,9 @@
void test_lock_two_uncontended()
{
- boost::fiber::mutex m1,m2;
+ boost::fibers::mutex m1,m2;
- boost::fiber::mutex::scoped_lock l1(m1,boost::defer_lock),
+ boost::fibers::mutex::scoped_lock l1(m1,boost::defer_lock),
l2(m2,boost::defer_lock);
BOOST_CHECK(!l1.owns_lock());
@@ -28,9 +28,9 @@
struct wait_data
{
- boost::fiber::mutex m;
+ boost::fibers::mutex m;
bool flag;
- boost::fiber::condition cond;
+ boost::fibers::condition cond;
wait_data():
flag(false)
@@ -38,7 +38,7 @@
void wait()
{
- boost::fiber::mutex::scoped_lock l(m);
+ boost::fibers::mutex::scoped_lock l(m);
while(!flag)
{
cond.wait(l);
@@ -50,7 +50,7 @@
{
boost::system_time const target=boost::get_system_time()+d;
- boost::fiber::mutex::scoped_lock l(m);
+ boost::fibers::mutex::scoped_lock l(m);
while(!flag)
{
if(!cond.timed_wait(l,target))
@@ -63,32 +63,32 @@
void signal()
{
- boost::fiber::mutex::scoped_lock l(m);
+ boost::fibers::mutex::scoped_lock l(m);
flag=true;
cond.notify_all();
}
};
-void lock_mutexes_slowly(boost::fiber::mutex* m1,boost::fiber::mutex* m2,wait_data* locked,wait_data* quit)
+void lock_mutexes_slowly(boost::fibers::mutex* m1,boost::fibers::mutex* m2,wait_data* locked,wait_data* quit)
{
- boost::lock_guard<boost::fiber::mutex> l1(*m1);
+ boost::lock_guard<boost::fibers::mutex> l1(*m1);
boost::this_fiber::sleep(boost::posix_time::milliseconds(500));
- boost::lock_guard<boost::fiber::mutex> l2(*m2);
+ boost::lock_guard<boost::fibers::mutex> l2(*m2);
locked->signal();
quit->wait();
}
-void lock_pair(boost::fiber::mutex* m1,boost::fiber::mutex* m2)
+void lock_pair(boost::fibers::mutex* m1,boost::fibers::mutex* m2)
{
boost::lock(*m1,*m2);
- boost::fiber::mutex::scoped_lock l1(*m1,boost::adopt_lock),
+ boost::fibers::mutex::scoped_lock l1(*m1,boost::adopt_lock),
l2(*m2,boost::adopt_lock);
}
void test_lock_two_other_thread_locks_in_order()
{
- boost::fiber::mutex m1,m2;
+ boost::fibers::mutex m1,m2;
wait_data locked;
wait_data release;
@@ -107,7 +107,7 @@
void test_lock_two_other_thread_locks_in_opposite_order()
{
- boost::fiber::mutex m1,m2;
+ boost::fibers::mutex m1,m2;
wait_data locked;
wait_data release;
@@ -126,9 +126,9 @@
void test_lock_five_uncontended()
{
- boost::fiber::mutex m1,m2,m3,m4,m5;
+ boost::fibers::mutex m1,m2,m3,m4,m5;
- boost::fiber::mutex::scoped_lock l1(m1,boost::defer_lock),
+ boost::fibers::mutex::scoped_lock l1(m1,boost::defer_lock),
l2(m2,boost::defer_lock),
l3(m3,boost::defer_lock),
l4(m4,boost::defer_lock),
@@ -149,23 +149,23 @@
BOOST_CHECK(l5.owns_lock());
}
-void lock_five_mutexes_slowly(boost::fiber::mutex* m1,boost::fiber::mutex* m2,boost::fiber::mutex* m3,boost::fiber::mutex* m4,boost::fiber::mutex* m5,
+void lock_five_mutexes_slowly(boost::fibers::mutex* m1,boost::fibers::mutex* m2,boost::fibers::mutex* m3,boost::fibers::mutex* m4,boost::fibers::mutex* m5,
wait_data* locked,wait_data* quit)
{
- boost::lock_guard<boost::fiber::mutex> l1(*m1);
+ boost::lock_guard<boost::fibers::mutex> l1(*m1);
boost::this_fiber::sleep(boost::posix_time::milliseconds(500));
- boost::lock_guard<boost::fiber::mutex> l2(*m2);
+ boost::lock_guard<boost::fibers::mutex> l2(*m2);
boost::this_fiber::sleep(boost::posix_time::milliseconds(500));
- boost::lock_guard<boost::fiber::mutex> l3(*m3);
+ boost::lock_guard<boost::fibers::mutex> l3(*m3);
boost::this_fiber::sleep(boost::posix_time::milliseconds(500));
- boost::lock_guard<boost::fiber::mutex> l4(*m4);
+ boost::lock_guard<boost::fibers::mutex> l4(*m4);
boost::this_fiber::sleep(boost::posix_time::milliseconds(500));
- boost::lock_guard<boost::fiber::mutex> l5(*m5);
+ boost::lock_guard<boost::fibers::mutex> l5(*m5);
locked->signal();
quit->wait();
}
-void lock_five(boost::fiber::mutex* m1,boost::fiber::mutex* m2,boost::fiber::mutex* m3,boost::fiber::mutex* m4,boost::fiber::mutex* m5)
+void lock_five(boost::fibers::mutex* m1,boost::fibers::mutex* m2,boost::fibers::mutex* m3,boost::fibers::mutex* m4,boost::fibers::mutex* m5)
{
boost::lock(*m1,*m2,*m3,*m4,*m5);
m1->unlock();
@@ -177,7 +177,7 @@
void test_lock_five_other_thread_locks_in_order()
{
- boost::fiber::mutex m1,m2,m3,m4,m5;
+ boost::fibers::mutex m1,m2,m3,m4,m5;
wait_data locked;
wait_data release;
@@ -196,7 +196,7 @@
void test_lock_five_other_thread_locks_in_different_order()
{
- boost::fiber::mutex m1,m2,m3,m4,m5;
+ boost::fibers::mutex m1,m2,m3,m4,m5;
wait_data locked;
wait_data release;
@@ -213,7 +213,7 @@
t.join();
}
-void lock_n(boost::fiber::mutex* mutexes,unsigned count)
+void lock_n(boost::fibers::mutex* mutexes,unsigned count)
{
boost::lock(mutexes,mutexes+count);
for(unsigned i=0;i<count;++i)
@@ -227,7 +227,7 @@
{
unsigned const num_mutexes=10;
- boost::fiber::mutex mutexes[num_mutexes];
+ boost::fibers::mutex mutexes[num_mutexes];
wait_data locked;
wait_data release;
Modified: sandbox/fiber/libs/fiber/test/test_manual_reset_event.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_manual_reset_event.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_manual_reset_event.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -22,7 +22,7 @@
int value = 0;
-void wait_fn( boost::fiber::manual_reset_event & ev)
+void wait_fn( boost::fibers::manual_reset_event & ev)
{
ev.wait();
++value;
@@ -31,8 +31,8 @@
void test_case_1()
{
value = 0;
- boost::fiber::manual_reset_event ev;
- boost::fiber::scheduler sched;
+ boost::fibers::manual_reset_event ev;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -61,8 +61,8 @@
void test_case_2()
{
value = 0;
- boost::fiber::manual_reset_event ev;
- boost::fiber::scheduler sched;
+ boost::fibers::manual_reset_event ev;
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -107,8 +107,8 @@
void test_case_3()
{
value = 0;
- boost::fiber::manual_reset_event ev( true);
- boost::fiber::scheduler sched;
+ boost::fibers::manual_reset_event ev( true);
+ boost::fibers::scheduler sched;
sched.make_fiber(
wait_fn,
@@ -130,7 +130,7 @@
void test_case_4()
{
- boost::fiber::manual_reset_event ev;
+ boost::fibers::manual_reset_event ev;
BOOST_CHECK_EQUAL( false, ev.try_wait() );
Modified: sandbox/fiber/libs/fiber/test/test_mutex.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_mutex.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_mutex.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -30,7 +30,7 @@
void operator()()
{
mutex_type mutex;
- boost::fiber::condition condition;
+ boost::fibers::condition condition;
// Test the lock's constructors.
{
@@ -59,12 +59,12 @@
void do_test_mutex()
{
- test_lock< boost::fiber::mutex >()();
+ test_lock< boost::fibers::mutex >()();
}
void test_case1()
{
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched;
sched.make_fiber( & do_test_mutex);
sched.run();
}
@@ -72,24 +72,24 @@
int value1 = 0;
int value2 = 0;
-void test_fn1( boost::fiber::mutex & mtx)
+void test_fn1( boost::fibers::mutex & mtx)
{
- boost::fiber::mutex::scoped_lock lk( mtx);
+ boost::fibers::mutex::scoped_lock lk( mtx);
++value1;
for ( int i = 0; i < 3; ++i)
boost::this_fiber::yield();
}
-void test_fn2( boost::fiber::mutex & mtx)
+void test_fn2( boost::fibers::mutex & mtx)
{
- boost::fiber::mutex::scoped_lock lk( mtx);
+ boost::fibers::mutex::scoped_lock lk( mtx);
++value2;
}
void test_case2()
{
- boost::fiber::mutex mtx;
- boost::fiber::scheduler sched;
+ boost::fibers::mutex mtx;
+ boost::fibers::scheduler sched;
sched.make_fiber( & test_fn1, boost::ref( mtx) );
sched.make_fiber( & test_fn2, boost::ref( mtx) );
Modified: sandbox/fiber/libs/fiber/test/test_rrp.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_rrp.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_rrp.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -23,19 +23,20 @@
void value2_fn()
{ value2 = 1; }
-// check empty() + size()
void test_case_1()
{
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched( boost::fibers::round_robin_policy);
BOOST_CHECK( sched.empty() );
BOOST_CHECK_EQUAL( std::size_t( 0), sched.size() );
BOOST_CHECK( ! sched.run() );
- sched.make_fiber( zero_args_fn);
+ boost::fiber f( boost::fibers::make_fiber( zero_args_fn) );
+ sched.submit_fiber( boost::move( f) );
BOOST_CHECK( ! sched.empty() );
BOOST_CHECK_EQUAL( std::size_t( 1), sched.size() );
- sched.make_fiber( zero_args_fn);
+ sched.submit_fiber(
+ boost::fibers::make_fiber( zero_args_fn) );
BOOST_CHECK( ! sched.empty() );
BOOST_CHECK_EQUAL( std::size_t( 2), sched.size() );
@@ -50,7 +51,7 @@
void test_case_2()
{
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched( boost::fibers::round_robin_policy);
sched.make_fiber( value1_fn);
sched.make_fiber( value2_fn);
Modified: sandbox/fiber/libs/fiber/test/test_unique_lock.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_unique_lock.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_unique_lock.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -45,8 +45,8 @@
void test_lock()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx);
BOOST_CHECK( lk);
BOOST_CHECK( lk.owns_lock() );
@@ -59,8 +59,8 @@
void test_defer_lock()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx, boost::defer_lock);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx, boost::defer_lock);
BOOST_CHECK( ! lk);
BOOST_CHECK( ! lk.owns_lock() );
@@ -73,9 +73,9 @@
void test_adopt_lock()
{
- boost::fiber::mutex mtx;
+ boost::fibers::mutex mtx;
mtx.lock();
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx, boost::adopt_lock);
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx, boost::adopt_lock);
BOOST_CHECK( lk);
BOOST_CHECK( lk.owns_lock() );
@@ -83,8 +83,8 @@
void test_try_lock()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx, boost::defer_lock);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx, boost::defer_lock);
BOOST_CHECK( ! lk);
BOOST_CHECK( ! lk.owns_lock() );
@@ -97,32 +97,32 @@
void test_lock_twice()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx);
- BOOST_CHECK_THROW( lk.lock(), boost::fiber::lock_error);
+ BOOST_CHECK_THROW( lk.lock(), boost::fibers::lock_error);
}
void test_try_lock_twice()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx);
- BOOST_CHECK_THROW( lk.try_lock(), boost::fiber::lock_error);
+ BOOST_CHECK_THROW( lk.try_lock(), boost::fibers::lock_error);
}
void test_unlock_twice()
{
- boost::fiber::mutex mtx;
- boost::fiber::unique_lock< boost::fiber::mutex > lk( mtx);
+ boost::fibers::mutex mtx;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk( mtx);
lk.unlock();
- BOOST_CHECK_THROW( lk.unlock(), boost::fiber::lock_error);
+ BOOST_CHECK_THROW( lk.unlock(), boost::fibers::lock_error);
}
void test_default_ctor()
{
- boost::fiber::unique_lock< boost::fiber::mutex > lk;
+ boost::fibers::unique_lock< boost::fibers::mutex > lk;
BOOST_CHECK( ! lk);
BOOST_CHECK( ! lk.owns_lock() );
@@ -130,9 +130,9 @@
void test_lock_concept()
{
- boost::fiber::mutex mtx1, mtx2, mtx3;
+ boost::fibers::mutex mtx1, mtx2, mtx3;
- boost::fiber::mutex::scoped_lock lk1( mtx1, boost::defer_lock),
+ boost::fibers::mutex::scoped_lock lk1( mtx1, boost::defer_lock),
lk2( mtx2, boost::defer_lock),
lk3( mtx3, boost::defer_lock);
@@ -152,7 +152,7 @@
dummy_mutex mtx1, mtx2;
mtx2.lock();
- boost::fiber::unique_lock< dummy_mutex > lk1( mtx1, boost::defer_lock),
+ boost::fibers::unique_lock< dummy_mutex > lk1( mtx1, boost::defer_lock),
lk2( mtx2, boost::defer_lock);
int res = boost::try_lock( lk1, lk2);
@@ -166,9 +166,9 @@
void test_swap()
{
- boost::fiber::mutex mtx1, mtx2;
+ boost::fibers::mutex mtx1, mtx2;
- boost::fiber::unique_lock< boost::fiber::mutex > lk1( mtx1), lk2( mtx2);
+ boost::fibers::unique_lock< boost::fibers::mutex > lk1( mtx1), lk2( mtx2);
BOOST_CHECK_EQUAL( lk1.mutex(), & mtx1);
BOOST_CHECK_EQUAL( lk2.mutex(), & mtx2);
Modified: sandbox/fiber/libs/fiber/test/test_utility.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/test/test_utility.cpp (original)
+++ sandbox/fiber/libs/fiber/test/test_utility.cpp 2009-11-11 13:21:32 EST (Wed, 11 Nov 2009)
@@ -49,7 +49,7 @@
void test_case_1()
{
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched;
sched.make_fiber( runs_as_fn);
BOOST_CHECK( sched.run() );
@@ -59,7 +59,7 @@
void test_case_2()
{
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched;
sched.make_fiber( get_id_fn);
BOOST_CHECK( sched.run() );
@@ -71,7 +71,7 @@
void test_case_3()
{
value = 0;
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched;
sched.make_fiber( yield_fn, 3);
BOOST_CHECK_EQUAL( 0, value);
@@ -94,7 +94,7 @@
void test_case_4()
{
value = 0;
- boost::fiber::scheduler sched;
+ boost::fibers::scheduler sched;
sched.make_fiber( cancel_fn, 5);
BOOST_CHECK_EQUAL( 0, value);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk