scripted-diff: Rename SingleThreadedSchedulerClient to SerialTaskRunner

-BEGIN VERIFY SCRIPT-
s() { git grep -l "$1" src | (grep -v "$3" || cat;) | xargs sed -i "s/$1/$2/g"; }

s 'SingleThreadedSchedulerClient'   'SerialTaskRunner'  ''
s 'SinglethreadedSchedulerClient'   'SerialTaskRunner'  ''
s 'm_schedulerClient'               'm_task_runner'     ''
s 'AddToProcessQueue'               'insert'            ''
s 'EmptyQueue'                      'flush'             ''
s 'CallbacksPending'                'size'              'validation'
sed -i '109s/CallbacksPending/size/' src/validationinterface.cpp
-END VERIFY SCRIPT-

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
TheCharlatan
2024-01-20 09:13:35 +01:00
parent 4abde2c4e3
commit 0d6d2b650d
4 changed files with 23 additions and 23 deletions

View File

@@ -45,9 +45,9 @@ public:
// We are not allowed to assume the scheduler only runs in one thread,
// but must ensure all callbacks happen in-order, so we end up creating
// our own queue here :(
SingleThreadedSchedulerClient m_schedulerClient;
SerialTaskRunner m_task_runner;
explicit MainSignalsImpl(CScheduler& scheduler LIFETIMEBOUND) : m_schedulerClient(scheduler) {}
explicit MainSignalsImpl(CScheduler& scheduler LIFETIMEBOUND) : m_task_runner(scheduler) {}
void Register(std::shared_ptr<CValidationInterface> callbacks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
{
@@ -101,12 +101,12 @@ CMainSignals::~CMainSignals() {}
void CMainSignals::FlushBackgroundCallbacks()
{
m_internals->m_schedulerClient.EmptyQueue();
m_internals->m_task_runner.flush();
}
size_t CMainSignals::CallbacksPending()
{
return m_internals->m_schedulerClient.CallbacksPending();
return m_internals->m_task_runner.size();
}
void CMainSignals::RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface> callbacks)
@@ -140,7 +140,7 @@ void CMainSignals::UnregisterAllValidationInterfaces()
void CMainSignals::CallFunctionInValidationInterfaceQueue(std::function<void()> func)
{
m_internals->m_schedulerClient.AddToProcessQueue(std::move(func));
m_internals->m_task_runner.insert(std::move(func));
}
void CMainSignals::SyncWithValidationInterfaceQueue()
@@ -162,7 +162,7 @@ void CMainSignals::SyncWithValidationInterfaceQueue()
do { \
auto local_name = (name); \
LOG_EVENT("Enqueuing " fmt, local_name, __VA_ARGS__); \
m_internals->m_schedulerClient.AddToProcessQueue([=] { \
m_internals->m_task_runner.insert([=] { \
LOG_EVENT(fmt, local_name, __VA_ARGS__); \
event(); \
}); \