]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_boost_asio_coroutine.h
2 // copy of needed class and macors from coroutine.hpp
4 // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef RGW_BOOST_ASIO_COROUTINE_H
11 #define RGW_BOOST_ASIO_COROUTINE_H
13 #ifndef HAVE_BOOST_ASIO_COROUTINE
26 /// Constructs a coroutine in its initial state.
27 coroutine() : value_(0) {}
29 /// Returns true if the coroutine is the child of a fork.
30 bool is_child() const { return value_
< 0; }
32 /// Returns true if the coroutine is the parent of a fork.
33 bool is_parent() const { return !is_child(); }
35 /// Returns true if the coroutine has reached its terminal state.
36 bool is_complete() const { return value_
== -1; }
39 friend class detail::coroutine_ref
;
49 coroutine_ref(coroutine
& c
) : value_(c
.value_
), modified_(false) {}
50 coroutine_ref(coroutine
* c
) : value_(c
->value_
), modified_(false) {}
51 ~coroutine_ref() { if (!modified_
) value_
= -1; }
52 operator int() const { return value_
; }
53 int& operator=(int v
) { modified_
= true; return value_
= v
; }
55 void operator=(const coroutine_ref
&);
64 #endif // HAVE_BOOST_ASIO_COROUTINE
66 #endif // RGW_BOOST_ASIO_COROUTINE_H