|
|
@ -230,36 +230,33 @@ private:
|
|
|
|
* Specialization for tasks with content that is move-only
|
|
|
|
* Specialization for tasks with content that is move-only
|
|
|
|
**********************************************************/
|
|
|
|
**********************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Capture>
|
|
|
|
class move_task_t
|
|
|
|
class moveable_task_t
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
moveable_task_t() = default;
|
|
|
|
move_task_t() = default;
|
|
|
|
template <typename Func>
|
|
|
|
template <typename Func>
|
|
|
|
moveable_task_t(Func&& f) : func(std::forward<Func>(f))
|
|
|
|
move_task_t(Func&& f) : task_ptr(new derived_task<Func>(std::forward<Func>(f)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator()() { (*task_ptr)(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct base_task {
|
|
|
|
|
|
|
|
virtual void operator()() = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
template <typename Func>
|
|
|
|
template <typename Func>
|
|
|
|
moveable_task_t(Func&& f, Capture&& c) : capture(std::forward<Capture>(c))
|
|
|
|
struct derived_task : public base_task {
|
|
|
|
{
|
|
|
|
derived_task(Func&& f_) : f(std::forward<Func>(f_)) {}
|
|
|
|
std::function<void(Capture)> ftmp{std::forward<Func>(f)};
|
|
|
|
void operator()() final { f(); }
|
|
|
|
func = [this, ftmp]() { ftmp(std::move(capture)); };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator()() { func(); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
std::function<void()> func;
|
|
|
|
Func f;
|
|
|
|
Capture capture;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Func, typename Capture>
|
|
|
|
std::unique_ptr<base_task> task_ptr;
|
|
|
|
moveable_task_t<Capture> bind_task(Func&& f, Capture&& c)
|
|
|
|
};
|
|
|
|
{
|
|
|
|
|
|
|
|
return moveable_task_t<Capture>{std::forward<Func>(f), std::forward<Capture>(c)};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Capture>
|
|
|
|
using multiqueue_task_handler = multiqueue_handler<move_task_t>;
|
|
|
|
using multiqueue_task_handler = multiqueue_handler<moveable_task_t<Capture> >;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace srslte
|
|
|
|
} // namespace srslte
|
|
|
|
|
|
|
|
|
|
|
|