Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This pull request allows people to select boost::future over std::future #218

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*.cpp
/*.hpp
*.exe
/boost
5 changes: 5 additions & 0 deletions asio/include/asio/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# define ASIO_DISABLE_BOOST_STATIC_CONSTANT 1
# define ASIO_DISABLE_BOOST_THROW_EXCEPTION 1
# define ASIO_DISABLE_BOOST_WORKAROUND 1
# define ASIO_DISABLE_BOOST_FUTURE 1
#else // defined(ASIO_STANDALONE)
# include <boost/config.hpp>
# include <boost/version.hpp>
Expand Down Expand Up @@ -732,6 +733,10 @@
# endif // !defined(ASIO_DISABLE_STD_FUTURE)
#endif // !defined(ASIO_HAS_STD_FUTURE)

#if !defined(ASIO_HAS_STD_FUTURE) && defined(ASIO_DISABLE_BOOST_FUTURE)
# define ASIO_DISABLE_FUTURE
#endif

// Standard library support for experimental::string_view.
#if !defined(ASIO_HAS_STD_STRING_VIEW)
# if !defined(ASIO_DISABLE_STD_STRING_VIEW)
Expand Down
2 changes: 2 additions & 0 deletions asio/include/asio/detail/cstddef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ namespace asio {

#if defined(ASIO_HAS_NULLPTR)
using std::nullptr_t;
#define ASIO_NULL nullptr
#else // defined(ASIO_HAS_NULLPTR)
struct nullptr_t {};
#define ASIO_NULL NULL
#endif // defined(ASIO_HAS_NULLPTR)

} // namespace asio
Expand Down
56 changes: 56 additions & 0 deletions asio/include/asio/detail/future.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// detail/array.hpp
// ~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef ASIO_DETAIL_FUTURE_HPP
#define ASIO_DETAIL_FUTURE_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include "asio/detail/config.hpp"

#if defined(ASIO_HAS_STD_FUTURE)
# include <future>
# include <exception>
#else // defined(ASIO_HAS_STD_FUTURE)
# if defined(BOOST_THREAD_VERSION) && (BOOST_THREAD_VERSION < 3)
# error BOOST_THREAD_VERSION must be defined to at least 3
# else
# if !defined(BOOST_THREAD_VERSION)
# define BOOST_THREAD_VERSION 3
# endif
# endif
# define ASIO_USING_BOOST_FUTURE
# include <boost/thread/future.hpp>
#endif // defined(ASIO_HAS_STD_FUTURE)

namespace asio {
namespace detail {

#if defined(ASIO_HAS_STD_FUTURE)
using std::future;
using std::packaged_task;
using std::promise;
#define ASIO_CURRENT_EXCEPTION std::current_exception()
#define ASIO_MAKE_EXCEPTION_PTR(_ex) std::make_exception_ptr(_ex)
using std::exception_ptr;
#else // defined(ASIO_HAS_STD_FUTURE)
using boost::future;
using boost::packaged_task;
using boost::promise;
#define ASIO_CURRENT_EXCEPTION boost::current_exception()
#define ASIO_MAKE_EXCEPTION_PTR(_ex) boost::copy_exception(_ex)
using boost::exception_ptr;
#endif // defined(ASIO_HAS_STD_FUTURE)
} // namespace detail
} // namespace asio

#endif // ASIO_DETAIL_FUTURE_HPP
3 changes: 3 additions & 0 deletions asio/include/asio/detail/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#if !defined(ASIO_HAS_STD_SHARED_PTR)
# include <boost/shared_ptr.hpp>
# include <boost/weak_ptr.hpp>
# include <boost/make_shared.hpp>
#endif // !defined(ASIO_HAS_STD_SHARED_PTR)

#if !defined(ASIO_HAS_STD_ADDRESSOF)
Expand All @@ -33,9 +34,11 @@ namespace detail {
#if defined(ASIO_HAS_STD_SHARED_PTR)
using std::shared_ptr;
using std::weak_ptr;
#define ASIO_ALLOCATE_SHARED std::allocate_shared
#else // defined(ASIO_HAS_STD_SHARED_PTR)
using boost::shared_ptr;
using boost::weak_ptr;
#define ASIO_ALLOCATE_SHARED boost::allocate_shared
#endif // defined(ASIO_HAS_STD_SHARED_PTR)

#if defined(ASIO_HAS_STD_ADDRESSOF)
Expand Down
12 changes: 6 additions & 6 deletions asio/include/asio/detail/winrt_async_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#if defined(ASIO_WINDOWS_RUNTIME)

#include <future>
#include "asio/detail/future.hpp"
#include "asio/detail/atomic_count.hpp"
#include "asio/detail/winrt_async_op.hpp"
#include "asio/error.hpp"
Expand Down Expand Up @@ -53,7 +53,7 @@ class winrt_async_manager
if (--outstanding_ops_ > 0)
{
// Block until last operation is complete.
std::future<void> f = promise_.get_future();
future<void> f = promise_.get_future();
f.wait();
}
}
Expand All @@ -64,7 +64,7 @@ class winrt_async_manager
using namespace Windows::Foundation;
using Windows::Foundation::AsyncStatus;

auto promise = std::make_shared<std::promise<asio::error_code>>();
auto promise = std::make_shared<promise<asio::error_code>>();
auto future = promise->get_future();

action->Completed = ref new AsyncActionCompletedHandler(
Expand Down Expand Up @@ -96,7 +96,7 @@ class winrt_async_manager
using namespace Windows::Foundation;
using Windows::Foundation::AsyncStatus;

auto promise = std::make_shared<std::promise<asio::error_code>>();
auto promise = std::make_shared<promise<asio::error_code>>();
auto future = promise->get_future();

operation->Completed = ref new AsyncOperationCompletedHandler<TResult>(
Expand Down Expand Up @@ -131,7 +131,7 @@ class winrt_async_manager
using namespace Windows::Foundation;
using Windows::Foundation::AsyncStatus;

auto promise = std::make_shared<std::promise<asio::error_code>>();
auto promise = std::make_shared<promise<asio::error_code>>();
auto future = promise->get_future();

operation->Completed
Expand Down Expand Up @@ -281,7 +281,7 @@ class winrt_async_manager
atomic_count outstanding_ops_;

// Used to keep wait for outstanding operations to complete.
std::promise<void> promise_;
promise<void> promise_;
};

} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion asio/include/asio/detail/winrt_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <codecvt>
#include <cstdlib>
#include <future>
#include "asio/detail/future.hpp"
#include <locale>
#include <robuffer.h>
#include <windows.storage.streams.h>
Expand Down
Loading