Files
core_future/tjp/core/future/WeakFuture.hpp
2026-03-06 09:28:09 -05:00

40 lines
599 B
C++
Executable File

// License: Modified MIT (NON-AI)
// See the LICENSE file in the root directory for license information.
// Copyright 2026 Timothy Prepscius
#pragma once
#include "Future.hpp"
namespace tjp {
namespace core {
// this may need to be strong this
template<typename T>
struct WeakFuture
{
typedef Future<T> F;
F f;
u8 number = 0;
void set(Future<T> &&f_)
{
auto number_ = ++number;
f = f_.then([this, number_](auto &&) {
if (number_ == number)
f = {};
});
};
auto &operator =(Future<T> &&f_)
{
set(std::move(f_));
return *this;
}
} ;
} // namespace
} // namespace