5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_CALL_STACK_HPP
12 #define BOOST_ASIO_DETAIL_CALL_STACK_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/detail/noncopyable.hpp>
21 #include <boost/asio/detail/tss_ptr.hpp>
27 // Helper class to determine whether or not the current thread is inside an
28 // invocation of io_service::run() for a specified io_service object.
29 template <typename Owner
>
33 // Context class automatically pushes an owner on to the stack.
38 // Push the owner on to the stack.
39 explicit context(Owner
* d
)
41 next_(call_stack
<Owner
>::top_
)
43 call_stack
<Owner
>::top_
= this;
46 // Pop the owner from the stack.
49 call_stack
<Owner
>::top_
= next_
;
53 friend class call_stack
<Owner
>;
55 // The owner associated with the context.
58 // The next element in the stack.
64 // Determine whether the specified owner is on the stack.
65 static bool contains(Owner
* d
)
70 if (elem
->owner_
== d
)
78 // The top of the stack of calls for the current thread.
79 static tss_ptr
<context
> top_
;
82 template <typename Owner
>
83 tss_ptr
<typename call_stack
<Owner
>::context
>
84 call_stack
<Owner
>::top_
;
90 #include <boost/asio/detail/pop_options.hpp>
92 #endif // BOOST_ASIO_DETAIL_CALL_STACK_HPP