Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
c5b44be
Common: add MoveOnlyFunction, a move-only callable wrapper
dayfine Oct 30, 2026
38bb6ae
Common: drop the noexcept move-assignment check from MoveOnlyFunction…
dayfine Oct 30, 2026
c8b3a32
Merge origin/main into common/move-only-function
dayfine Oct 30, 2026
87071ad
Merge origin/main into common/move-only-function
dayfine Oct 31, 2026
93487aa
Common: hold thread pool tasks in MoveOnlyFunction
dayfine Oct 31, 2026
ce9c531
Common: hold Thread, FireForgetDispatcher and ScheduledTaskRunner tas…
dayfine Oct 31, 2026
1657c8d
CommonTools: hold async session commands and detector callbacks in Mo…
dayfine Oct 31, 2026
be7bcf8
PABotBase2: hold message handlers and the rumble callback in MoveOnly…
dayfine Oct 31, 2026
352d5ae
Integrations: hold the Discord webhook finish callback in MoveOnlyFun…
dayfine Oct 31, 2026
981b0aa
Merge origin/main into common/move-only-function-migrate
dayfine Nov 2, 2026
332ca01
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 2, 2026
e114e19
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 2, 2026
9d4d4f3
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 2, 2026
237375c
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 2, 2026
c7a5fda
Merge origin/main into common/move-only-function-migrate
dayfine Nov 3, 2026
f389c6c
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 3, 2026
6fadae6
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 3, 2026
f566281
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 3, 2026
8a61117
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 3, 2026
4bb2d90
Merge origin/main into common/move-only-function-migrate
dayfine Nov 4, 2026
1cf6c74
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 4, 2026
63edae8
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 4, 2026
800abbb
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 4, 2026
1659ac6
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 4, 2026
089d1d4
Merge origin/main into common/move-only-function-migrate
dayfine Nov 6, 2026
e024467
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 6, 2026
22bfa8a
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 6, 2026
c05d6f7
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 6, 2026
0efe24e
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 6, 2026
34da3a2
Merge origin/main into common/move-only-function-migrate
dayfine Nov 7, 2026
0e2a1e0
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 7, 2026
28eeaf7
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 7, 2026
1b61593
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 7, 2026
63a3388
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 7, 2026
69123f5
Merge origin/main into common/move-only-function-migrate
dayfine Nov 8, 2026
0a9a51b
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 8, 2026
0cacb96
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 8, 2026
44a95ee
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 8, 2026
8174274
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 8, 2026
9b00659
Merge origin/main into common/move-only-function-migrate
dayfine Nov 9, 2026
62deacd
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 9, 2026
53da97e
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 9, 2026
12427d0
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 9, 2026
6eb258f
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 9, 2026
32ee4bc
Merge origin/main into common/move-only-function-migrate
dayfine Nov 10, 2026
959b210
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 10, 2026
d5af40f
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 10, 2026
ca8f9ea
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 10, 2026
a1f84f3
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 10, 2026
4f5bfae
Merge origin/main into common/move-only-function-migrate
dayfine Nov 11, 2026
616c972
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 11, 2026
c7f0dde
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 11, 2026
ffd9f3e
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 11, 2026
6a0bf11
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 11, 2026
419c9b3
Merge origin/main into common/move-only-function-migrate
dayfine Nov 12, 2026
b839e91
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 12, 2026
e91c580
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 12, 2026
7dc95a8
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 12, 2026
ce42e44
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 12, 2026
67358a5
Merge origin/main into common/move-only-function-migrate
dayfine Nov 13, 2026
bbb1e55
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 13, 2026
ab4c129
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 13, 2026
d9700a6
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 13, 2026
9ff5b90
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 13, 2026
17f7d91
Merge origin/main into common/move-only-function-migrate
dayfine Nov 14, 2026
be1cb68
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 14, 2026
0567f10
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 14, 2026
ac1578a
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 14, 2026
a791210
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 14, 2026
451bcab
Merge origin/main into common/move-only-function-migrate
dayfine Nov 16, 2026
127567c
Merge origin/common/move-only-function-migrate into common/move-only-…
dayfine Nov 16, 2026
626578c
Merge origin/common/move-only-tasks-threads into common/move-only-ses…
dayfine Nov 16, 2026
46ff92c
Merge origin/common/move-only-sessions-detectors into common/move-onl…
dayfine Nov 16, 2026
9bb0c2a
Merge origin/common/move-only-pabotbase2-handlers into common/move-on…
dayfine Nov 16, 2026
5153f30
Merge origin/main into common/move-only-discord-webhook
dayfine Nov 18, 2026
9b5f208
Merge origin/main into common/move-only-discord-webhook
dayfine Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/Backends/AsyncTask_Default.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#ifndef PokemonAutomation_AsyncTask_Default_H
#define PokemonAutomation_AsyncTask_Default_H

#include <functional>
#include <atomic>
#include <exception>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Concurrency/SpinPause.h"
#include "Common/Cpp/Concurrency/Mutex.h"
#include "Common/Cpp/Concurrency/ConditionVariable.h"
Expand Down Expand Up @@ -50,7 +50,7 @@ class AsyncTask_Cpp : public AsyncTaskCore{
pause();
}
}
AsyncTask_Cpp(std::function<void()> task)
AsyncTask_Cpp(MoveOnlyFunction<void()> task)
: m_task(std::move(task))
, m_state(State::NOT_STARTED)
{}
Expand Down Expand Up @@ -102,7 +102,7 @@ class AsyncTask_Cpp : public AsyncTaskCore{


private:
std::function<void()> m_task;
MoveOnlyFunction<void()> m_task;
std::atomic<State> m_state;

std::exception_ptr m_exception;
Expand Down
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/Backends/ThreadPool_Default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ WallDuration ThreadPool_Default::cpu_time() const{
return ret;
}

AsyncTask ThreadPool_Default::dispatch(std::function<void()>&& func){
AsyncTask ThreadPool_Default::dispatch(MoveOnlyFunction<void()>&& func){
AsyncTask task;
{
std::unique_lock<Mutex> lg(m_lock);
Expand All @@ -114,7 +114,7 @@ AsyncTask ThreadPool_Default::dispatch(std::function<void()>&& func){
m_thread_cv.notify_one();
return task;
}
AsyncTask ThreadPool_Default::dispatch_now_blocking(std::function<void()>&& func){
AsyncTask ThreadPool_Default::dispatch_now_blocking(MoveOnlyFunction<void()>&& func){
AsyncTask task;
{
std::unique_lock<Mutex> lg(m_lock);
Expand All @@ -138,7 +138,7 @@ AsyncTask ThreadPool_Default::dispatch_now_blocking(std::function<void()>&& func
m_thread_cv.notify_one();
return task;
}
AsyncTask ThreadPool_Default::try_dispatch_now(std::function<void()>& func){
AsyncTask ThreadPool_Default::try_dispatch_now(MoveOnlyFunction<void()>& func){
AsyncTask task;
{
std::lock_guard<Mutex> lg(m_lock);
Expand Down
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/Backends/ThreadPool_Default.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class ThreadPool_Default final : public ThreadPool{


public:
[[nodiscard]] virtual AsyncTask dispatch(std::function<void()>&& func) override;
[[nodiscard]] virtual AsyncTask dispatch_now_blocking(std::function<void()>&& func) override;
[[nodiscard]] virtual AsyncTask try_dispatch_now(std::function<void()>& func) override;
[[nodiscard]] virtual AsyncTask dispatch(MoveOnlyFunction<void()>&& func) override;
[[nodiscard]] virtual AsyncTask dispatch_now_blocking(MoveOnlyFunction<void()>&& func) override;
[[nodiscard]] virtual AsyncTask try_dispatch_now(MoveOnlyFunction<void()>& func) override;

virtual void run_in_parallel(
const std::function<void(size_t index)>& func,
Expand Down
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/Backends/Thread_Qt.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace PokemonAutomation{

// PIMPL implementation - hides std::thread from header
struct Thread::Data : public QThread{
Data(std::function<void()>&& function)
Data(MoveOnlyFunction<void()>&& function)
: m_function(std::move(function))
// , m_finished(false)
{
Expand Down Expand Up @@ -69,7 +69,7 @@ struct Thread::Data : public QThread{
// cout << "exiting: " << this << endl;
}

std::function<void()> m_function;
MoveOnlyFunction<void()> m_function;

std::atomic<bool> m_finished;
};
Expand All @@ -95,7 +95,7 @@ Thread::Thread() = default;
// Main constructor - starts thread immediately with given function
// - Uses CONSTRUCT_TOKEN to construct Pimpl<Data> with Data constructor
// - Thread starts running immediately (same as std::thread behavior)
Thread::Thread(std::function<void()>&& function)
Thread::Thread(MoveOnlyFunction<void()>&& function)
: m_data(CONSTRUCT_TOKEN, std::move(function))
{}

Expand Down
4 changes: 2 additions & 2 deletions Common/Cpp/Concurrency/Backends/Thread_StdThread.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace PokemonAutomation{
struct Thread::Data{
std::thread m_thread;

Data(std::function<void()>&& function)
Data(MoveOnlyFunction<void()>&& function)
: m_thread(std::move(function))
{}
};
Expand All @@ -45,7 +45,7 @@ Thread::Thread() = default;
// Main constructor - starts thread immediately with given function
// - Uses CONSTRUCT_TOKEN to construct Pimpl<Data> with Data constructor
// - Thread starts running immediately (same as std::thread behavior)
Thread::Thread(std::function<void()>&& function)
Thread::Thread(MoveOnlyFunction<void()>&& function)
: m_data(CONSTRUCT_TOKEN, std::move(function))
{}

Expand Down
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/Backends/Thread_StdThreadDetach.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ struct Thread::Data{

std::thread m_thread;

Data(std::function<void()>&& function)
Data(MoveOnlyFunction<void()>&& function)
: m_stopped(false)
, m_thread(
[this, function = std::move(function)]{
[this, function = std::move(function)]() mutable{
function();
// std::lock_guard<std::mutex> lg(m_lock);
// m_stopped = true;
Expand Down Expand Up @@ -60,7 +60,7 @@ Thread::Thread() = default;
// Main constructor - starts thread immediately with given function
// - Uses CONSTRUCT_TOKEN to construct Pimpl<Data> with Data constructor
// - Thread starts running immediately (same as std::thread behavior)
Thread::Thread(std::function<void()>&& function)
Thread::Thread(MoveOnlyFunction<void()>&& function)
: m_data(CONSTRUCT_TOKEN, std::move(function))
{}

Expand Down
4 changes: 2 additions & 2 deletions Common/Cpp/Concurrency/FireForgetDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FireForgetDispatcher::~FireForgetDispatcher(){
stop();
}

void FireForgetDispatcher::dispatch(std::function<void()>&& func){
void FireForgetDispatcher::dispatch(MoveOnlyFunction<void()>&& func){
std::lock_guard<Mutex> lg(m_lock);
m_queue.emplace_back(std::move(func));
m_cv.notify_one();
Expand All @@ -58,7 +58,7 @@ void FireForgetDispatcher::dispatch(std::function<void()>&& func){

void FireForgetDispatcher::thread_loop(){
while (true){
std::function<void()> task;
MoveOnlyFunction<void()> task;
{
std::unique_lock<Mutex> lg(m_lock);
if (m_stopping){
Expand Down
6 changes: 3 additions & 3 deletions Common/Cpp/Concurrency/FireForgetDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define PokemonAutomation_FireForgetDispatcher_H

#include <deque>
#include <functional>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Mutex.h"
#include "ConditionVariable.h"
#include "Thread.h"
Expand All @@ -23,7 +23,7 @@ class FireForgetDispatcher{

// Dispatch the specified task and return a handle to it.
// Call "handle->wait()" to wait for the task to finish.
void dispatch(std::function<void()>&& func);
void dispatch(MoveOnlyFunction<void()>&& func);

void stop();

Expand All @@ -32,7 +32,7 @@ class FireForgetDispatcher{
void thread_loop();

private:
std::deque<std::function<void()>> m_queue;
std::deque<MoveOnlyFunction<void()>> m_queue;
Thread m_thread;
bool m_stopping;
Mutex m_lock;
Expand Down
4 changes: 2 additions & 2 deletions Common/Cpp/Concurrency/ScheduledTaskRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ WallClock ScheduledTaskRunner::next_event() const{
}
return m_schedule.begin()->first;
}
void ScheduledTaskRunner::add_event(WallClock time, std::function<void()> callback){
void ScheduledTaskRunner::add_event(WallClock time, MoveOnlyFunction<void()> callback){
std::lock_guard<Mutex> lg(m_lock);
if (m_stopped){
return;
}
m_schedule.emplace(time, std::move(callback));
m_cv.notify_all();
}
void ScheduledTaskRunner::add_event(std::chrono::milliseconds time_from_now, std::function<void()> callback){
void ScheduledTaskRunner::add_event(std::chrono::milliseconds time_from_now, MoveOnlyFunction<void()> callback){
std::lock_guard<Mutex> lg(m_lock);
if (m_stopped){
return;
Expand Down
7 changes: 4 additions & 3 deletions Common/Cpp/Concurrency/ScheduledTaskRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define PokemonAutomation_ScheduledTaskRunner_H

#include <map>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Time.h"
//#include "Common/Cpp/CancellableScope.h"
#include "Common/Cpp/Concurrency/Mutex.h"
Expand All @@ -33,8 +34,8 @@ class ScheduledTaskRunner{
// events are scheduled.
WallClock next_event() const;

void add_event(WallClock time, std::function<void()> callback);
void add_event(std::chrono::milliseconds time_from_now, std::function<void()> callback);
void add_event(WallClock time, MoveOnlyFunction<void()> callback);
void add_event(std::chrono::milliseconds time_from_now, MoveOnlyFunction<void()> callback);

// virtual bool cancel(std::exception_ptr exception) noexcept override;

Expand All @@ -46,7 +47,7 @@ class ScheduledTaskRunner{
ConditionVariable m_cv;
bool m_stopped;

std::multimap<WallClock, std::function<void()>> m_schedule;
std::multimap<WallClock, MoveOnlyFunction<void()>> m_schedule;

AsyncTask m_runner;
};
Expand Down
4 changes: 2 additions & 2 deletions Common/Cpp/Concurrency/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef PokemonAutomation_Concurrency_Thread_H
#define PokemonAutomation_Concurrency_Thread_H

#include <functional>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Containers/Pimpl.h"

namespace PokemonAutomation{
Expand All @@ -42,7 +42,7 @@ class Thread{

// Constructor - starts thread immediately with given function like std::thread
// Function is moved (not copied) for efficiency
Thread(std::function<void()>&& function);
Thread(MoveOnlyFunction<void()>&& function);

// Returns true if Thread has valid data (not default-constructed or moved-from)
// and not joined.
Expand Down
7 changes: 4 additions & 3 deletions Common/Cpp/Concurrency/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define PokemonAutomation_ThreadPool_H

#include <functional>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Time.h"

namespace PokemonAutomation{
Expand All @@ -40,17 +41,17 @@ class ThreadPool{

// Dispatch the function and return immediately.
// The function is not guaranteed to begin running immediately.
[[nodiscard]] virtual AsyncTask dispatch(std::function<void()>&& func) = 0;
[[nodiscard]] virtual AsyncTask dispatch(MoveOnlyFunction<void()>&& func) = 0;

// Dispatch the function and begin running now.
// If there are no threads available, it waits until there are.
// This function will not return until the function has begin running.
[[nodiscard]] virtual AsyncTask dispatch_now_blocking(std::function<void()>&& func) = 0;
[[nodiscard]] virtual AsyncTask dispatch_now_blocking(MoveOnlyFunction<void()>&& func) = 0;

// Try to dispatch the function and begin running now.
// Returns null if no threads are available. "func" will be moved-from only on success.
// This function returns immediately.
[[nodiscard]] virtual AsyncTask try_dispatch_now(std::function<void()>& func) = 0;
[[nodiscard]] virtual AsyncTask try_dispatch_now(MoveOnlyFunction<void()>& func) = 0;

// Run function for all the indices [start, end).
// Lower indices are not allowed to block on higher indices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

//#include "Common/Cpp/Concurrency/ReverseLockGuard.h"
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Concurrency/AsyncTask.h"
#include "CommonFramework/ImageTypes/ImageRGB32_Qt.h"
#include "CommonFramework/Tools/GlobalThreadPools.h"
Expand Down Expand Up @@ -100,7 +101,7 @@ bool SnapshotManager::try_dispatch_conversion(uint64_t seqnum, QVideoFrame frame
}

try{
std::function<void()> lambda = [=, this, frame = std::move(frame)](){
MoveOnlyFunction<void()> lambda = [=, this, frame = std::move(frame)](){
convert(seqnum, std::move(frame), timestamp);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef PokemonAutomation_CommonTools_InterruptableCommands_H
#define PokemonAutomation_CommonTools_InterruptableCommands_H

#include <functional>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Concurrency/Mutex.h"
#include "Common/Cpp/Concurrency/ConditionVariable.h"
#include "Common/Cpp/Concurrency/AsyncTask.h"
Expand Down Expand Up @@ -44,7 +44,7 @@ class AsyncCommandSession final : private Cancellable{
// previous `dispatch()` while a new `dispatch()` presses button A and button B
// at the same time, button A is not released during the transition.
// You can use it to adjust button state continuously without interruption.
void dispatch(std::function<void(ControllerContextType&)>&& lambda);
void dispatch(MoveOnlyFunction<void(ControllerContextType&)>&& lambda);

// Wait for currently running command to finish.
void wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ template <typename ControllerType>
struct AsyncCommandSession<ControllerType>::CommandSet{
CommandSet(
CancellableScope& parent, ControllerType& controller,
std::function<void(ControllerContextType&)>&& lambda
MoveOnlyFunction<void(ControllerContextType&)>&& lambda
);
CancellableHolder<CancellableScope> scope;
ControllerContextType context;
std::function<void(ControllerContextType&)> commands;
MoveOnlyFunction<void(ControllerContextType&)> commands;
};



template <typename ControllerType>
AsyncCommandSession<ControllerType>::CommandSet::CommandSet(
CancellableScope& parent, ControllerType& controller,
std::function<void(ControllerContextType&)>&& lambda
MoveOnlyFunction<void(ControllerContextType&)>&& lambda
)
: scope(parent)
, context(scope, controller)
Expand Down Expand Up @@ -97,7 +97,7 @@ void AsyncCommandSession<ControllerType>::stop_command(){
}
}
template <typename ControllerType>
void AsyncCommandSession<ControllerType>::dispatch(std::function<void(ControllerContextType&)>&& lambda){
void AsyncCommandSession<ControllerType>::dispatch(MoveOnlyFunction<void(ControllerContextType&)>&& lambda){
auto scope_check = m_sanitizer.check_scope();

// Construct the CommandSet outside the lock.
Expand Down
6 changes: 3 additions & 3 deletions SerialPrograms/Source/CommonTools/Async/SuperControlSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <vector>
#include <map>
#include <chrono>
#include <functional>
#include "Common/Cpp/MoveOnlyFunction.h"
#include "Common/Cpp/Time.h"

namespace PokemonAutomation{
Expand Down Expand Up @@ -58,7 +58,7 @@ class SuperControlSession{
void operator+=(VisualInferenceCallback& callback);
void operator+=(AudioInferenceCallback& callback);

void register_state_command(size_t state, std::function<bool()>&& action);
void register_state_command(size_t state, MoveOnlyFunction<bool()>&& action);


protected:
Expand Down Expand Up @@ -91,7 +91,7 @@ class SuperControlSession{
std::vector<AudioInferenceCallback*> m_audio_callbacks;

// These are actions
std::map<size_t, std::function<bool()>> m_state_actions;
std::map<size_t, MoveOnlyFunction<bool()>> m_state_actions;

private:
// Run-time state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void SuperControlSession<ControllerType>::operator+=(AudioInferenceCallback& cal
m_audio_callbacks.emplace_back(&callback);
}
template <typename ControllerType>
void SuperControlSession<ControllerType>::register_state_command(size_t state, std::function<bool()>&& action){
void SuperControlSession<ControllerType>::register_state_command(size_t state, MoveOnlyFunction<bool()>&& action){
auto iter = m_state_actions.find(state);
if (iter != m_state_actions.end()){
throw InternalProgramError(&m_stream.logger(), PA_CURRENT_FUNCTION, "Duplicate State Enum: " + std::to_string(state));
Expand Down
Loading