thread_ref.qbk
来自「Boost provides free peer-reviewed portab」· QBK 代码 · 共 1,065 行 · 第 1/2 页
QBK
1,065 行
bool operator==(const id& y) const; bool operator!=(const id& y) const; bool operator<(const id& y) const; bool operator>(const id& y) const; bool operator<=(const id& y) const; bool operator>=(const id& y) const; template<class charT, class traits> friend std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const id& x); };[section:constructor Default constructor] id();[variablelist[[Effects:] [Constructs a __thread_id__ instance that represents __not_a_thread__.]][[Throws:] [Nothing]]][endsect][section:is_equal `operator==`] bool operator==(const id& y) const;[variablelist[[Returns:] [`true` if `*this` and `y` both represent the same thread of execution, or both represent __not_a_thread__, `false`otherwise.]][[Throws:] [Nothing]]][endsect][section:not_equal `operator!=`] bool operator!=(const id& y) const;[variablelist[[Returns:] [`true` if `*this` and `y` represent different threads of execution, or one represents a thread of execution, andthe other represent __not_a_thread__, `false` otherwise.]][[Throws:] [Nothing]]][endsect][section:less_than `operator<`] bool operator<(const id& y) const;[variablelist[[Returns:] [`true` if `*this!=y` is `true` and the implementation-defined total order of __thread_id__ values places `*this` before`y`, `false` otherwise.]][[Throws:] [Nothing]][[Note:] [A __thread_id__ instance representing __not_a_thread__ will always compare less than an instance representing a thread ofexecution.]]][endsect][section:greater_than `operator>`] bool operator>(const id& y) const;[variablelist[[Returns:] [`y<*this`]][[Throws:] [Nothing]]][endsect][section:less_than_or_equal `operator>=`] bool operator<=(const id& y) const;[variablelist[[Returns:] [`!(y<*this)`]][[Throws:] [Nothing]]][endsect][section:greater_than_or_equal `operator>=`] bool operator>=(const id& y) const;[variablelist[[Returns:] [`!(*this<y)`]][[Throws:] [Nothing]]][endsect][section:stream_out Friend `operator<<`] template<class charT, class traits> friend std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const id& x);[variablelist[[Effects:] [Writes a representation of the __thread_id__ instance `x` to the stream `os`, such that the representation of twoinstances of __thread_id__ `a` and `b` is the same if `a==b`, and different if `a!=b`.]][[Returns:] [`os`]]][endsect][endsect][endsect][section:this_thread Namespace `this_thread`][section:get_id Non-member function `get_id()`] #include <boost/thread/thread.hpp> namespace this_thread { thread::id get_id(); }[variablelist[[Returns:] [An instance of __thread_id__ that represents that currently executing thread.]][[Throws:] [__thread_resource_error__ if an error occurs.]]][endsect][section:interruption_point Non-member function `interruption_point()`] #include <boost/thread/thread.hpp> namespace this_thread { void interruption_point(); }[variablelist[[Effects:] [Check to see if the current thread has been interrupted.]][[Throws:] [__thread_interrupted__ if __interruption_enabled__ and __interruption_requested__ both return `true`.]]][endsect][section:interruption_requested Non-member function `interruption_requested()`] #include <boost/thread/thread.hpp> namespace this_thread { bool interruption_requested(); }[variablelist[[Returns:] [`true` if interruption has been requested for the current thread, `false` otherwise.]][[Throws:] [Nothing.]]][endsect][section:interruption_enabled Non-member function `interruption_enabled()`] #include <boost/thread/thread.hpp> namespace this_thread { bool interruption_enabled(); }[variablelist[[Returns:] [`true` if interruption has been enabled for the current thread, `false` otherwise.]][[Throws:] [Nothing.]]][endsect][section:sleep Non-member function `sleep()`] #include <boost/thread/thread.hpp> namespace this_thread { template<typename TimeDuration> void sleep(TimeDuration const& rel_time); }[variablelist[[Effects:] [Suspends the current thread until the specified time has elapsed.]][[Throws:] [__thread_interrupted__ if the current thread of execution is interrupted.]][[Notes:] [`sleep()` is one of the predefined __interruption_points__.]]][endsect][section:yield Non-member function `yield()`] #include <boost/thread/thread.hpp> namespace this_thread { void yield(); }[variablelist[[Effects:] [Gives up the remainder of the current thread's time slice, to allow other threads to run.]][[Throws:] [Nothing.]]][endsect][section:disable_interruption Class `disable_interruption`] #include <boost/thread/thread.hpp> namespace this_thread { class disable_interruption { public: disable_interruption(); ~disable_interruption(); }; }`boost::this_thread::disable_interruption` disables interruption for the current thread on construction, and restores the priorinterruption state on destruction. Instances of `disable_interruption` cannot be copied or moved.[section:constructor Constructor] disable_interruption();[variablelist[[Effects:] [Stores the current state of __interruption_enabled__ and disables interruption for the current thread.]][[Postconditions:] [__interruption_enabled__ returns `false` for the current thread.]][[Throws:] [Nothing.]]][endsect][section:destructor Destructor] ~disable_interruption();[variablelist[[Preconditions:] [Must be called from the same thread from which `*this` was constructed.]][[Effects:] [Restores the current state of __interruption_enabled__ for the current thread to that prior to the construction of `*this`.]][[Postconditions:] [__interruption_enabled__ for the current thread returns the value stored in the constructor of `*this`.]][[Throws:] [Nothing.]]][endsect][endsect][section:restore_interruption Class `restore_interruption`] #include <boost/thread/thread.hpp> namespace this_thread { class restore_interruption { public: explicit restore_interruption(disable_interruption& disabler); ~restore_interruption(); }; }On construction of an instance of `boost::this_thread::restore_interruption`, the interruption state for the current thread isrestored to the interruption state stored by the constructor of the supplied instance of __disable_interruption__. When the instanceis destroyed, interruption is again disabled. Instances of `restore_interruption` cannot be copied or moved.[section:constructor Constructor] explicit restore_interruption(disable_interruption& disabler);[variablelist[[Preconditions:] [Must be called from the same thread from which `disabler` was constructed.]][[Effects:] [Restores the current state of __interruption_enabled__ for the current thread to that prior to the construction of `disabler`.]][[Postconditions:] [__interruption_enabled__ for the current thread returns the value stored in the constructor of `disabler`.]][[Throws:] [Nothing.]]][endsect][section:destructor Destructor] ~restore_interruption();[variablelist[[Preconditions:] [Must be called from the same thread from which `*this` was constructed.]][[Effects:] [Disables interruption for the current thread.]][[Postconditions:] [__interruption_enabled__ for the current thread returns `false`.]][[Throws:] [Nothing.]]][endsect][endsect][section:atthreadexit Non-member function template `at_thread_exit()`] #include <boost/thread/thread.hpp> template<typename Callable> void at_thread_exit(Callable func);[variablelist[[Effects:] [A copy of `func` is placed inthread-specific storage. This copy is invoked when the current threadexits (even if the thread has been interrupted).]][[Postconditions:] [A copy of `func` has been saved for invocation on thread exit.]][[Throws:] [`std::bad_alloc` if memory cannot be allocated for the copy of the function, __thread_resource_error__ if any othererror occurs within the thread library. Any exception thrown whilst copying `func` into internal storage.]]][endsect][endsect][section:threadgroup Class `thread_group`] #include <boost/thread/thread.hpp> class thread_group: private noncopyable { public: thread_group(); ~thread_group(); template<typename F> thread* create_thread(F threadfunc); void add_thread(thread* thrd); void remove_thread(thread* thrd); void join_all(); void interrupt_all(); int size() const; };`thread_group` provides for a collection of threads that are related in some fashion. New threads can be added to the group with`add_thread` and `create_thread` member functions. `thread_group` is not copyable or movable.[section:constructor Constructor] thread_group();[variablelist[[Effects:] [Create a new thread group with no threads.]]][endsect][section:destructor Destructor] ~thread_group();[variablelist[[Effects:] [Destroy `*this` and `delete` all __thread__ objects in the group.]]][endsect][section:create_thread Member function `create_thread()`] template<typename F> thread* create_thread(F threadfunc);[variablelist[[Effects:] [Create a new __thread__ object as-if by `new thread(threadfunc)` and add it to the group.]][[Postcondition:] [`this->size()` is increased by one, the new thread is running.]][[Returns:] [A pointer to the new __thread__ object.]]][endsect][section:add_thread Member function `add_thread()`] void add_thread(thread* thrd);[variablelist[[Precondition:] [The expression `delete thrd` is well-formed and will not result in undefined behaviour.]][[Effects:] [Take ownership of the __thread__ object pointed to by `thrd` and add it to the group.]][[Postcondition:] [`this->size()` is increased by one.]]][endsect][section:remove_thread Member function `remove_thread()`] void remove_thread(thread* thrd);[variablelist[[Effects:] [If `thrd` is a member of the group, remove it without calling `delete`.]][[Postcondition:] [If `thrd` was a member of the group, `this->size()` is decreased by one.]]][endsect][section:join_all Member function `join_all()`] void join_all();[variablelist[[Effects:] [Call `join()` on each __thread__ object in the group.]][[Postcondition:] [Every thread in the group has terminated.]][[Note:] [Since __join__ is one of the predefined __interruption_points__, `join_all()` is also an interruption point.]]][endsect][section:interrupt_all Member function `interrupt_all()`] void interrupt_all();[variablelist[[Effects:] [Call `interrupt()` on each __thread__ object in the group.]]][endsect][section:size Member function `size()`] int size();[variablelist[[Returns:] [The number of threads in the group.]][[Throws:] [Nothing.]]][endsect][endsect][endsect]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?