Commit 4981497a authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook GitHub Bot

Type-erase most of Core implementation

Summary:
`Core<T>` instantiations share a large part of the implementation, but in the current shape the code is duplicated for each instantiation. This diff moves whatever possible to a common base class.

This diff only splits the typed and untyped parts, for ease of review. The untyped parts are moved to the cpp file in D22371900.

Reviewed By: andriigrynenko

Differential Revision: D22371898

fbshipit-source-id: db48c202d0bdcbefbebe150e7c7d9f35e06687d0
parent aac9d77f
......@@ -310,12 +310,13 @@ void FutureBase<T>::raise(exception_wrapper exception) {
}
template <class T>
template <class F>
void FutureBase<T>::setCallback_(
CoreCallback&& func,
F&& func,
futures::detail::InlineContinuation allowInline) {
throwIfContinued();
getCore().setCallback(
std::move(func), RequestContext::saveContext(), allowInline);
std::forward<F>(func), RequestContext::saveContext(), allowInline);
}
template <class T>
......
......@@ -122,7 +122,6 @@ template <class T>
class FutureBase {
protected:
using Core = futures::detail::Core<T>;
using CoreCallback = typename Core::Callback;
public:
typedef T value_type;
......@@ -269,9 +268,8 @@ class FutureBase {
/// This needs to be public because it's used by make* and when*, and it's
/// not worth listing all those and their fancy template signatures as
/// friends. But it's not for public consumption.
void setCallback_(
CoreCallback&& func,
InlineContinuation = InlineContinuation::forbid);
template <class F>
void setCallback_(F&& func, InlineContinuation = InlineContinuation::forbid);
/// Provides a threadsafe back-channel so the consumer's thread can send an
/// interrupt-object to the producer's thread.
......
This diff is collapsed.
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