By: Mathias Stearn
Please provide feedback either by email, or on #sg15-tooling in cpplang.slack.com.
This is an alternative to a proposal that I'm sure was offered with good intentions, but that I and several others shuddered at the sight of:
template <typename T> | |
struct semi_lazy { | |
struct promise_type { | |
std::optional<T> val; | |
std::function<void()> defer; | |
suspend_never initial_suspend() { return {}; } | |
suspend_always final_suspend() { return {}; } | |
void return_value(T v) { | |
val.emplace(std::move(v)); |
#include <utility> | |
#include <exception> | |
// This is probably customizable | |
using Error = std::exception_ptr; | |
template <typename R, typename T> | |
concept ValueReciever = requires (T a, R r) { | |
std::move(r).value(std::move(a)); | |
}; |
template <typename T> | |
struct ValueReceiver { | |
virtual void value(T) = 0; | |
}; | |
template <typename T> | |
struct ValueOrErrorReceiver : ValueReceiver<T> { | |
virtual void value(T) = 0; | |
virtual void error(std::exception_ptr) = 0; | |
}; |
#include <cstdlib> | |
#include <boost/optional.hpp> | |
#include <string> | |
using boost::optional; | |
template <typename T> | |
struct Future{}; | |
template <typename T> |
#include <functional> | |
#include <exception> | |
#include <optional> | |
#include <memory> | |
#include <cassert> | |
#include <atomic> | |
#include <iostream> | |
#include <mutex> | |
#include <condition_variable> | |
#include <thread> |
By: Mathias Stearn
Please provide feedback either by email, or on #sg15-tooling in cpplang.slack.com.
This is an alternative to a proposal that I'm sure was offered with good intentions, but that I and several others shuddered at the sight of:
#include <tuple> | |
#include <optional> | |
#include <functional> | |
///////////////////// | |
/// PRIMARY TEMPLATES | |
template <typename T> | |
struct future_then_return_traits { | |
// Future::then(cb) for a callback that returns T, |
enum State {INIT, PHASE2, DONE}; | |
std::atomic<State> state{INIT}; | |
int non_atomic = 0; // placeholder for actual data. | |
auto phase1 = std::thread([&] { | |
non_atomic = 1; | |
state.store(PHASE2, std::memory_order_release); | |
auto phase2 = std::thread([&] { |
Document Number: | P0911R0 |
---|---|
Date: | 2018-02-03 |
Project: | Programming Language C++, CWG, LWG |
Revises: | none |
Reply to: | gorn@microsoft.com |