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 ASIO_DETAIL_CALL_STACK_HPP
12
#define ASIO_DETAIL_CALL_STACK_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/noncopyable.hpp"
21
#include "asio/detail/tss_ptr.hpp"
26
// Helper class to determine whether or not the current thread is inside an
27
// invocation of io_service::run() for a specified io_service object.
28
template <typename Owner>
32
// Context class automatically pushes an owner on to the stack.
37
// Push the owner on to the stack.
38
explicit context(Owner* d)
40
next_(call_stack<Owner>::top_)
42
call_stack<Owner>::top_ = this;
45
// Pop the owner from the stack.
48
call_stack<Owner>::top_ = next_;
52
friend class call_stack<Owner>;
54
// The owner associated with the context.
57
// The next element in the stack.
63
// Determine whether the specified owner is on the stack.
64
static bool contains(Owner* d)
69
if (elem->owner_ == d)
77
// The top of the stack of calls for the current thread.
78
static tss_ptr<context> top_;
81
template <typename Owner>
82
tss_ptr<typename call_stack<Owner>::context>
83
call_stack<Owner>::top_;
88
#include "asio/detail/pop_options.hpp"
90
#endif // ASIO_DETAIL_CALL_STACK_HPP