예제 #1
0
#if defined BOOST_THREAD_PROVIDES_INVOKE
#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke
#define BOOST_THREAD_INVOKE_RET_VOID_CALL
#elif defined BOOST_THREAD_PROVIDES_INVOKE_RET
#define BOOST_THREAD_INVOKE_RET_VOID detail::invoke<void>
#define BOOST_THREAD_INVOKE_RET_VOID_CALL
#else
#define BOOST_THREAD_INVOKE_RET_VOID boost::bind
#define BOOST_THREAD_INVOKE_RET_VOID_CALL ()
#endif


#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)

  template<typename Function, class ...ArgTypes>
  inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(ArgTypes)... args)
  {
    if (thread_detail::enter_once_region(flag))
    {
      BOOST_TRY
      {
        BOOST_THREAD_INVOKE_RET_VOID(
                        thread_detail::decay_copy(boost::forward<Function>(f)),
                        thread_detail::decay_copy(boost::forward<ArgTypes>(args))...
        ) BOOST_THREAD_INVOKE_RET_VOID_CALL;
      }
      BOOST_CATCH (...)
      {
        thread_detail::rollback_once_region(flag);
        BOOST_RETHROW
      }
예제 #2
0
        return ex.closed();
    }

    /**
     * \par Effects
     * The specified closure will be scheduled for execution at some point in the future.
     * If invoked closure throws an exception the executor will call std::terminate, as is the case with threads.
     *
     * \par Synchronization
     * Ccompletion of closure on a particular thread happens before destruction of thread's thread local variables.
     *
     * \par Throws
     * \c sync_queue_is_closed if the thread pool is closed.
     * Whatever exception that can be throw while storing the closure.
     */
    void submit(BOOST_THREAD_RV_REF(work) closure) {
        ex.submit(boost::move(closure));
    }
//    void submit(work& closure) {
//      ex.submit(closure);
//    }


    /**
     * \par Effects
     * Try to execute one task.
     *
     * \par Returns
     * Whether a task has been executed.
     *
     * \par Throws
    typedef typename externally_locked_stream<Stream, RecursiveMutex>::mutex_type mutex_type;

    BOOST_THREAD_MOVABLE_ONLY( stream_guard)

    stream_guard(externally_locked_stream<Stream, RecursiveMutex>& mtx) :
      mtx_(&mtx)
    {
      mtx.lock();
    }

    stream_guard(externally_locked_stream<Stream, RecursiveMutex>& mtx, adopt_lock_t) :
      mtx_(&mtx)
    {
    }

    stream_guard(BOOST_THREAD_RV_REF(stream_guard) rhs) BOOST_NOEXCEPT
    : mtx_(rhs.mtx_)
    {
      rhs.mtx_= 0;
    }

    ~stream_guard()
    {
      if (mtx_ != 0) mtx_->unlock();
    }

    bool owns_lock(const mutex_type * l) const BOOST_NOEXCEPT
    {
      return l == mtx_->mutex();
    }
예제 #4
0
    {
        return boost::move(t);
    }
#endif
#endif

struct X
{
public:
    int i;

    BOOST_THREAD_MOVABLE_ONLY(X)
    X():
        i(42)
    {}
    X(BOOST_THREAD_RV_REF(X) other):
        i(BOOST_THREAD_RV(other).i)
    {
      BOOST_THREAD_RV(other).i=0;
    }
    ~X()
    {}
};
namespace boost {
  BOOST_THREAD_DCL_MOVABLE(X)
}

int make_int()
{
    return 42;
}
예제 #5
0
    sync_queue();
    template <typename Range>
    explicit sync_queue(Range range);
    ~sync_queue();

    // Observers
    bool empty() const;
    bool full() const;
    size_type size() const;
    bool closed() const;

    // Modifiers
    void close();

    void push(const value_type& x);
    void push(BOOST_THREAD_RV_REF(value_type) x);
    bool try_push(const value_type& x);
    bool try_push(BOOST_THREAD_RV_REF(value_type) x);
    bool try_push(no_block_tag, const value_type& x);
    bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);

    // Observers/Modifiers
    void pull(value_type&);
    void pull(ValueType& elem, bool & closed);
    // enable_if is_nothrow_copy_movable<value_type>
    value_type pull();
    shared_ptr<ValueType> ptr_pull();
    bool try_pull(value_type&);
    bool try_pull(no_block_tag,value_type&);
    shared_ptr<ValueType> try_pull();
예제 #6
0
    template <class F, class A1, class A2>
    strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) :
      t_(boost::forward<F>(f), boost::forward<A1>(a1), boost::forward<A2>(a2)) {}
    template <class F, class A1, class A2, class A3>
    strict_scoped_thread(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2, BOOST_THREAD_FWD_REF(A3) a3) :
      t_(boost::forward<F>(f), boost::forward<A1>(a1), boost::forward<A2>(a2), boost::forward<A3>(a3)) {}
#endif

    /**
     * Constructor from the thread to own.
     *
     * @param t: the thread to own.
     *
     * Effects: move the thread to own @c t.
     */
    explicit strict_scoped_thread(BOOST_THREAD_RV_REF(thread) t) BOOST_NOEXCEPT :
    t_(boost::move(t))
    {
    }

    /**
     * Destructor
     * Effects: Call the CallableThread functor before destroying the owned thread.
     * Remark: The CallableThread should not throw when joining the thread as the scoped variable is on a scope outside the thread function.
     */
    ~strict_scoped_thread()
    {
      CallableThread on_destructor;

      on_destructor(t_);
    }
예제 #7
0
public:
  long data_;

  static int n_moves;
  static int n_copies;
  BOOST_THREAD_COPYABLE_AND_MOVABLE(A)
  static void reset()
  {
    n_moves=0;
    n_copies=0;
  }

  explicit A(long i) : data_(i)
  {
  }
  A(BOOST_THREAD_RV_REF(A) a) : data_(BOOST_THREAD_RV(a).data_)
  {
    BOOST_THREAD_RV(a).data_ = -1;
    ++n_moves;
  }
  A& operator=(BOOST_THREAD_RV_REF(A) a)
  {
    data_ = BOOST_THREAD_RV(a).data_;
    BOOST_THREAD_RV(a).data_ = -1;
    ++n_moves;
    return *this;
  }
  A(const A& a) : data_(a.data_)
  {
    ++n_copies;
  }
예제 #8
0
    // Modifiers
    void close() { queue.close(); }


    void pull(value_type& x) { queue.pull(x); };
    // enable_if is_nothrow_copy_movable<value_type>
    value_type pull() { return queue.pull(); }

    queue_op_status try_pull(value_type& x)  { return queue.try_pull(x); }

    queue_op_status nonblocking_pull(value_type& x)  { return queue.nonblocking_pull(x); }

    queue_op_status wait_pull(value_type& x) { return queue.wait_pull(x); }

    void push(BOOST_THREAD_RV_REF(value_type) x) { queue.push(boost::move(x)); }
    queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.try_push(boost::move(x)); }
    queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.nonblocking_push(boost::move(x)); }
    queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue.wait_push(boost::move(x)); }
  };

  template <typename Queue>
  class queue_adaptor_copyable_and_movable :
    public boost::queue_base<typename Queue::value_type, typename Queue::size_type>
  {
      Queue queue;
  public:
    typedef typename Queue::value_type value_type;
    typedef typename Queue::size_type size_type;

    // Constructors/Assignment/Destructors
예제 #9
0
      void_functor_barrier_reseter(unsigned int size, BOOST_THREAD_RV_REF(F) funct)
      : size_(size), fct_(boost::move(funct))
      {}
      template <typename F>
      void_functor_barrier_reseter(unsigned int size, F& funct)
      : size_(size), fct_(funct)
      {}

      BOOST_THREAD_MOVABLE(void_functor_barrier_reseter)
      //BOOST_THREAD_COPYABLE_AND_MOVABLE(void_functor_barrier_reseter)

      void_functor_barrier_reseter(void_functor_barrier_reseter const& other) BOOST_NOEXCEPT :
      size_(other.size_), fct_(other.fct_)
      {
      }
      void_functor_barrier_reseter(BOOST_THREAD_RV_REF(void_functor_barrier_reseter) other) BOOST_NOEXCEPT :
      size_(BOOST_THREAD_RV(other).size_), fct_(BOOST_THREAD_RV(other).fct_)
      //size_(BOOST_THREAD_RV(other).size_), fct_(boost::move(BOOST_THREAD_RV(other).fct_))
      {
      }

      unsigned int operator()()
      {
        fct_();
        return size_;
      }
    };
    struct void_fct_ptr_barrier_reseter
    {
      unsigned int size_;
      void(*fct_)();
예제 #10
0
파일: invoker.hpp 프로젝트: CasparCG/Client
      //csbl::tuple<Fpd, Argsd...> f_;
      csbl::tuple<Fp, Args...> f_;

    public:
      BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker)
      //typedef typename invoke_of<_Fp, _Args...>::type Rp;
      typedef typename result_of<Fp(Args...)>::type result_type;

      template <class F, class ... As>
      BOOST_SYMBOL_VISIBLE
      explicit invoker(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args)
      : f_(boost::forward<F>(f), boost::forward<As>(args)...)
      {}

      BOOST_SYMBOL_VISIBLE
      invoker(BOOST_THREAD_RV_REF(invoker) f) : f_(boost::move(BOOST_THREAD_RV(f).f_))
      {}

      BOOST_SYMBOL_VISIBLE
      invoker( const invoker& f) : f_(f.f_)
      {}

      BOOST_SYMBOL_VISIBLE
      invoker& operator=(BOOST_THREAD_RV_REF(invoker) f)
      {
        f_ = boost::move(BOOST_THREAD_RV(f).f_);
      }

      BOOST_SYMBOL_VISIBLE
      invoker& operator=( BOOST_THREAD_COPY_ASSIGN_REF(invoker) f)
      {
예제 #11
0
파일: invoke.hpp 프로젝트: SCUSIT/PDAL

#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
    ! defined(BOOST_NO_SFINAE_EXPR) && \
    ! defined(BOOST_NO_CXX11_DECLTYPE) && \
    ! defined(BOOST_NO_CXX11_DECLTYPE_N3276) && \
    ! defined(BOOST_NO_CXX11_AUTO)

#define BOOST_THREAD_PROVIDES_INVOKE

#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
// bullets 1 and 2

template <class Fp, class A0, class ...Args>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args)
-> decltype((pdalboost::forward<A0>(a0).*f)(pdalboost::forward<Args>(args)...))
{
    return (pdalboost::forward<A0>(a0).*f)(pdalboost::forward<Args>(args)...);
}

template <class Fp, class A0, class ...Args>
inline auto
invoke(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(A0) a0, BOOST_THREAD_RV_REF(Args) ...args)
-> decltype(((*pdalboost::forward<A0>(a0)).*f)(pdalboost::forward<Args>(args)...))
{
    return ((*pdalboost::forward<A0>(a0)).*f)(pdalboost::forward<Args>(args)...);
}

// bullets 3 and 4
  long data_;

public:
  explicit A(long i) :
    data_(i)
  {
  }

  long operator()(long i, long j) const
  {
    if (j == 'z') BOOST_THROW_EXCEPTION( E(6) );
    return data_ + i + j;
  }
};

void func0_mv(BOOST_THREAD_RV_REF(boost::packaged_task<double(int, char)>) p)
//void func0(boost::packaged_task<double(int, char)> p)
{
  boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
  p.make_ready_at_thread_exit(3, 'a');
}
void func0(boost::packaged_task<double(int, char)> *p)
{
  boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
  p->make_ready_at_thread_exit(3, 'a');
}
void func1(boost::packaged_task<double(int, char)> *p)
{
  boost::this_thread::sleep_for(boost::chrono::milliseconds(500));
  p->make_ready_at_thread_exit(3, 'z');
}
예제 #13
0
      };
    public:
      BOOST_THREAD_COPYABLE_AND_MOVABLE(nullary_function)

      explicit nullary_function(void (*f)()):
      impl(new impl_type_ptr(f))
      {}

#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
      template<typename F>
      explicit nullary_function(F& f):
      impl(new impl_type<F>(f))
      {}
#endif
      template<typename F>
      nullary_function(BOOST_THREAD_RV_REF(F) f):
      impl(new impl_type<typename decay<F>::type>(thread_detail::decay_copy(boost::forward<F>(f))))
      {}

      nullary_function()
        : impl()
      {
      }
      nullary_function(nullary_function const& other) BOOST_NOEXCEPT :
      impl(other.impl)
      {
      }
      nullary_function(BOOST_THREAD_RV_REF(nullary_function) other) BOOST_NOEXCEPT :
#if defined BOOST_NO_CXX11_SMART_PTR
      impl(BOOST_THREAD_RV(other).impl)
      {
예제 #14
0
    void pull(value_type& x) { queue->pull_back(x); }
    // enable_if is_nothrow_copy_movable<value_type>
    value_type pull()  { return queue->pull_back(); }

    queue_op_status try_push(const value_type& x) { return queue->try_push_back(x); }

    queue_op_status try_pull(value_type& x) { return queue->try_pull_back(x); }

    queue_op_status nonblocking_push(const value_type& x) { return queue->nonblocking_push_back(x); }

    queue_op_status nonblocking_pull(value_type& x) { return queue->nonblocking_pull_back(x); }

    queue_op_status wait_push(const value_type& x) { return queue->wait_push_back(x); }
    queue_op_status wait_pull(value_type& x) { return queue->wait_pull_back(x); }

    void push(BOOST_THREAD_RV_REF(value_type) x) { queue->push_back(mars_boost::move(x)); }
    queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->try_push_back(mars_boost::move(x)); }
    queue_op_status nonblocking_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->nonblocking_push_back(mars_boost::move(x)); }
    queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x) { return queue->wait_push_back(mars_boost::move(x)); }
  };

  template <typename Queue>
  class deque_front_view
  {
   Queue* queue;
  public:
    typedef typename Queue::value_type value_type;
    typedef typename Queue::size_type size_type;

    // Constructors/Assignment/Destructors
    deque_front_view(Queue& q) BOOST_NOEXCEPT : queue(&q) {}
예제 #15
0
    virtual bool closed() const = 0;

    // Modifiers
    virtual void close() = 0;

    virtual void pull_front(value_type&) = 0;
    // enable_if is_nothrow_movable<value_type>
    virtual value_type pull_front() = 0;

    virtual queue_op_status try_pull_front(value_type&) = 0;

    virtual queue_op_status nonblocking_pull_front(value_type&) = 0;

    virtual queue_op_status wait_pull_front(value_type& elem) = 0;

    virtual void push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
    virtual queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
    virtual queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
    virtual queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) = 0;
  };


  template <typename ValueType, class SizeType>
  class deque_base_copyable_and_movable
  {
  public:
    typedef ValueType value_type;
    typedef SizeType size_type;
    // Constructors/Assignment/Destructors
    virtual ~deque_base_copyable_and_movable() {};
예제 #16
0
        return queue.pull_front();
    }

    queue_op_status try_pull_front(value_type& x)  {
        return queue.try_pull_front(x);
    }

    queue_op_status nonblocking_pull_front(value_type& x)  {
        return queue.nonblocking_pull_front(x);
    }

    queue_op_status wait_pull_front(value_type& x) {
        return queue.wait_pull_front(x);
    }

    void push_back(BOOST_THREAD_RV_REF(value_type) x) {
        queue.push_back(boost::move(x));
    }
    queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x) {
        return queue.try_push_back(boost::move(x));
    }
    queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x) {
        return queue.nonblocking_push_back(boost::move(x));
    }
    queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x) {
        return queue.wait_push_back(boost::move(x));
    }
};

template <typename Queue>
class deque_adaptor_copyable_and_movable :
예제 #17
0
    inline ~sync_queue();

    // Observers
    inline bool empty() const;
    inline bool full() const;
    inline size_type size() const;
    inline bool closed() const;

    // Modifiers
    inline void close();

#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
    inline void push(const value_type& x);
    inline bool try_push(const value_type& x);
    inline bool try_push(no_block_tag, const value_type& x);
    inline void push(BOOST_THREAD_RV_REF(value_type) x);
    inline bool try_push(BOOST_THREAD_RV_REF(value_type) x);
    inline bool try_push(no_block_tag, BOOST_THREAD_RV_REF(value_type) x);
#endif
    inline void push_back(const value_type& x);
    inline queue_op_status try_push_back(const value_type& x);
    inline queue_op_status nonblocking_push_back(const value_type& x);
    inline queue_op_status wait_push_back(const value_type& x);
    inline void push_back(BOOST_THREAD_RV_REF(value_type) x);
    inline queue_op_status try_push_back(BOOST_THREAD_RV_REF(value_type) x);
    inline queue_op_status nonblocking_push_back(BOOST_THREAD_RV_REF(value_type) x);
    inline queue_op_status wait_push_back(BOOST_THREAD_RV_REF(value_type) x);


    // Observers/Modifiers
#ifndef BOOST_THREAD_QUEUE_DEPRECATE_OLD
예제 #18
0
    T data;
    time_point time;

    BOOST_THREAD_COPYABLE_AND_MOVABLE(scheduled_type)

    scheduled_type(T const& pdata, time_point tp) : data(pdata), time(tp) {}
    scheduled_type(BOOST_THREAD_RV_REF(T) pdata, time_point tp) : data(boost::move(pdata)), time(tp) {}

    scheduled_type(scheduled_type const& other) : data(other.data), time(other.time) {}
    scheduled_type& operator=(BOOST_THREAD_COPY_ASSIGN_REF(scheduled_type) other) {
        data = other.data;
        time = other.time;
        return *this;
    }

    scheduled_type(BOOST_THREAD_RV_REF(scheduled_type) other) : data(boost::move(other.data)), time(other.time) {}
    scheduled_type& operator=(BOOST_THREAD_RV_REF(scheduled_type) other) {
        data = boost::move(other.data);
        time = other.time;
        return *this;
    }

    bool time_not_reached() const
    {
        return time > clock::now();
    }

    bool operator <(const scheduled_type<T> other) const
    {
        return this->time > other.time;
    }
예제 #19
0
    // Observers/Modifiers
    inline void pull(value_type&);
    // enable_if is_nothrow_copy_movable<value_type>
    inline value_type pull();

    inline queue_op_status try_pull(value_type&);
    inline queue_op_status nonblocking_pull(value_type&);
    inline queue_op_status wait_pull(ValueType& elem);

  private:

    inline queue_op_status try_pull(value_type& x, unique_lock<mutex>& lk);
    inline queue_op_status wait_pull(value_type& x, unique_lock<mutex>& lk);
    inline queue_op_status try_push(const value_type& x, unique_lock<mutex>& lk);
    inline queue_op_status wait_push(const value_type& x, unique_lock<mutex>& lk);
    inline queue_op_status try_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);
    inline queue_op_status wait_push(BOOST_THREAD_RV_REF(value_type) x, unique_lock<mutex>& lk);

    inline void pull(value_type& elem, unique_lock<mutex>& )
    {
      elem = boost::move(super::data_.front());
      super::data_.pop_front();
    }
    inline value_type pull(unique_lock<mutex>& )
    {
      value_type e = boost::move(super::data_.front());
      super::data_.pop_front();
      return boost::move(e);
    }

    inline void push(const value_type& elem, unique_lock<mutex>& lk)
예제 #20
0
{
  A() :
    value(0)
  {
  }
  A(int i) :
    value(i)
  {
  }
  A(int i, int j) :
    value(i+j)
  {
  }
  BOOST_THREAD_MOVABLE_ONLY(A)

  A(BOOST_THREAD_RV_REF(A) rhs)
  {
    if(rhs.value==0)
    throw 9;
    else
    {
      value=rhs.value;
      rhs.value=0;
    }
  }
  A& operator=(BOOST_THREAD_RV_REF(A) rhs)
  {
    if(rhs.value==0)
    throw 9;
    else
    {
예제 #21
0
    BOOST_THREAD_COPYABLE_AND_MOVABLE( externally_locked )
    /**
     * Requires: T is a model of CopyConstructible.
     * Effects: Constructs an externally locked object copying the cloaked type.
     */
    BOOST_CONSTEXPR externally_locked(mutex_type& mtx, const T& obj) :
      obj_(obj), mtx_(&mtx)
    {
    }

    /**
     * Requires: T is a model of Movable.
     * Effects: Constructs an externally locked object by moving the cloaked type.
     */
    BOOST_CONSTEXPR externally_locked(mutex_type& mtx, BOOST_THREAD_RV_REF(T) obj) :
      obj_(move(obj)), mtx_(&mtx)
    {
    }

    /**
     * Requires: T is a model of DefaultConstructible.
     * Effects: Constructs an externally locked object initializing the cloaked type with the default constructor.
     */
    externally_locked(mutex_type& mtx) :
      obj_(), mtx_(&mtx)
    {
    }

    /**
     *  Move constructor
예제 #22
0
#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
    ! defined(BOOST_NO_CXX11_HDR_TUPLE)

    template <class Fp, class ... Args>
    class async_func
    {
      std::tuple<Fp, Args...> f_;

    public:
      BOOST_THREAD_MOVABLE_ONLY( async_func)
      //typedef typename invoke_of<_Fp, _Args...>::type Rp;
      typedef typename result_of<Fp(Args...)>::type result_type;

      BOOST_SYMBOL_VISIBLE
      explicit async_func(BOOST_THREAD_RV_REF(Fp) f, BOOST_THREAD_RV_REF(Args)... args)
      : f_(boost::move(f), boost::move(args)...)
      {}

      BOOST_SYMBOL_VISIBLE
      async_func(BOOST_THREAD_RV_REF(async_func) f) : f_(boost::move(f.f_))
      {}

      result_type operator()()
      {
        typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index;
        return execute(Index());
      }
    private:
      template <size_t ...Indices>
      result_type
    BOOST_THREAD_COPYABLE_AND_MOVABLE( externally_locked )
    /**
     * Requires: T is a model of CopyConstructible.
     * Effects: Constructs an externally locked object copying the cloaked type.
     */
    externally_locked(mutex_type& mtx, const T& obj) :
      obj_(obj), mtx_(&mtx)
    {
    }

    /**
     * Requires: T is a model of Movable.
     * Effects: Constructs an externally locked object by moving the cloaked type.
     */
    externally_locked(mutex_type& mtx, BOOST_THREAD_RV_REF(T) obj) :
      obj_(move(obj)), mtx_(&mtx)
    {
    }

    /**
     * Requires: T is a model of DefaultConstructible.
     * Effects: Constructs an externally locked object initializing the cloaked type with the default constructor.
     */
    externally_locked(mutex_type& mtx) // BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(T()))
    : obj_(), mtx_(&mtx)
    {
    }

    /**
     *  Copy constructor