1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #ifndef BOOST_ASIO_DETAIL_CALL_STACK_HPP
- #define BOOST_ASIO_DETAIL_CALL_STACK_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/push_options.hpp>
- #include <boost/asio/detail/noncopyable.hpp>
- #include <boost/asio/detail/tss_ptr.hpp>
- namespace boost {
- namespace asio {
- namespace detail {
- template <typename Owner>
- class call_stack
- {
- public:
-
- class context
- : private noncopyable
- {
- public:
-
- explicit context(Owner* d)
- : owner_(d),
- next_(call_stack<Owner>::top_)
- {
- call_stack<Owner>::top_ = this;
- }
-
- ~context()
- {
- call_stack<Owner>::top_ = next_;
- }
- private:
- friend class call_stack<Owner>;
-
- Owner* owner_;
-
- context* next_;
- };
- friend class context;
-
- static bool contains(Owner* d)
- {
- context* elem = top_;
- while (elem)
- {
- if (elem->owner_ == d)
- return true;
- elem = elem->next_;
- }
- return false;
- }
- private:
-
- static tss_ptr<context> top_;
- };
- template <typename Owner>
- tss_ptr<typename call_stack<Owner>::context>
- call_stack<Owner>::top_;
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|