
#ifndef PLS_INTERNAL_SCHEDULING_PARALLEL_RESULT_H_
#define PLS_INTERNAL_SCHEDULING_PARALLEL_RESULT_H_

#include <utility>
#include "pls/internal/data_structures/delayed_initialization.h"

namespace pls {
namespace internal {
namespace scheduling {

// Used to more enforce the use of parallel_results
class parallel_result_base {};

template<typename T>
class parallel_result : public parallel_result_base {
 public:
  using value_type = T;

  parallel_result() = default;
  parallel_result(parallel_result &&other) noexcept : val_{std::move(other.val_)} {}
  parallel_result(const parallel_result &other) noexcept : val_{other.val_} {}

  parallel_result(T val) : val_{std::move(val)} {}

  bool fast_path() { return val_.initialized(); }
  T &value() { return val_.object(); }

 private:
  data_structures::delayed_initialization<T> val_;
};

}
}
}

#endif //PLS_INTERNAL_SCHEDULING_PARALLEL_RESULT_H_
