Commit 5c8fc1b6 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook GitHub Bot

delete folly/experimental/coro/Wait.h

Summary:
This code is not used anywhere, and does not currently build.
`operator delete()` was calling `folly_coro_async_malloc()` with the wrong
number of arguments.  Presumably it meant to actually call
`folly_coro_async_free()`.

Reviewed By: yfeldblum, iahs

Differential Revision: D32824148

fbshipit-source-id: bf4266cd33ecc39539dc5fdafd761d8f56d6060d
parent 33a47683
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <future>
#include <folly/experimental/coro/Coroutine.h>
#if FOLLY_HAS_COROUTINES
namespace folly {
namespace coro {
class Wait {
public:
class promise_type {
public:
static void* operator new(std::size_t size) {
return ::folly_coro_async_malloc(size);
}
void operator delete(void* ptr, std::size_t size) {
::folly_coro_async_malloc(ptr, size);
}
Wait get_return_object() { return Wait(promise_.get_future()); }
suspend_never initial_suspend() noexcept { return {}; }
suspend_never final_suspend() noexcept { return {}; }
void return_void() { promise_.set_value(); }
void unhandled_exception() {
promise_.set_exception(std::current_exception());
}
private:
std::promise<void> promise_;
};
explicit Wait(std::future<void> future) : future_(std::move(future)) {}
Wait(Wait&&) = default;
void detach() { future_ = {}; }
~Wait() {
if (future_.valid()) {
future_.get();
}
}
private:
std::future<void> future_;
};
} // namespace coro
} // namespace folly
#endif // FOLLY_HAS_COROUTINES
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment