Skip to content

Commit fc1a950

Browse files
committed
Fix stop program responsiveness.
1 parent a66ba84 commit fc1a950

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

SerialPrograms/Source/Controllers/Controller.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ class ControllerContext final : public CancellableScope{
185185
using ControllerType = Type;
186186

187187
public:
188-
ControllerContext(ControllerType& botbase)
189-
: m_controller(botbase)
188+
ControllerContext(ControllerType& controller)
189+
: m_controller(controller)
190190
{}
191-
ControllerContext(CancellableScope& parent, ControllerType& botbase)
192-
: m_controller(botbase)
191+
ControllerContext(CancellableScope& parent, ControllerType& controller)
192+
: m_controller(controller)
193193
{
194194
attach(parent);
195195
}

SerialPrograms/Source/NintendoSwitch/DevPrograms/JoyconProgram.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
#include "NintendoSwitch/Controllers/NintendoSwitch_Joycon.h"
99
#include "JoyconProgram.h"
1010

11-
// REMOVE
12-
#include <iostream>
13-
using std::cout;
14-
using std::endl;
11+
//#include <iostream>
12+
//using std::cout;
13+
//using std::endl;
1514

1615
namespace PokemonAutomation{
1716
namespace NintendoSwitch{

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_MultiSwitchProgramSession.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ void MultiSwitchProgramSession::run_program_instance(MultiSwitchProgramEnvironme
107107
try{
108108
m_option.instance().program(env, scope);
109109
for (size_t c = 0; c < consoles; c++){
110-
env.consoles[c].controller().wait_for_all(&scope);
110+
ControllerContext<AbstractController> context(scope, env.consoles[c].controller());
111+
context.wait_for_all_requests();
111112
}
112113
}catch (...){
113114
for (size_t c = 0; c < consoles; c++){

SerialPrograms/Source/NintendoSwitch/Framework/NintendoSwitch_SingleSwitchProgramSession.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
#include "CommonFramework/Options/Environment/PerformanceOptions.h"
1313
#include "CommonFramework/Notifications/ProgramInfo.h"
1414
#include "CommonFramework/Notifications/ProgramNotifications.h"
15-
#include "NintendoSwitch/Controllers/NintendoSwitch_ProController.h"
1615
#include "NintendoSwitch_SingleSwitchProgramOption.h"
1716
#include "NintendoSwitch_SingleSwitchProgramSession.h"
1817

19-
2018
#define PA_CATCH_PROGRAM_SYSTEM_EXCEPTIONS
2119

20+
//#include <iostream>
21+
//using std::cout;
22+
//using std::endl;
2223

2324

2425
namespace PokemonAutomation{
@@ -81,7 +82,9 @@ void SingleSwitchProgramSession::run_program_instance(SingleSwitchProgramEnviron
8182
#ifdef PA_CATCH_PROGRAM_SYSTEM_EXCEPTIONS
8283
try{
8384
m_option.instance().program(env, scope);
84-
env.console.controller().wait_for_all(&scope);
85+
86+
ControllerContext<AbstractController> context(scope, env.console.controller());
87+
context.wait_for_all_requests();
8588
}catch (...){
8689
env.console.controller().cancel_all_commands();
8790
m_scope.store(nullptr, std::memory_order_release);
@@ -97,7 +100,7 @@ void SingleSwitchProgramSession::run_program_instance(SingleSwitchProgramEnviron
97100
}
98101
void SingleSwitchProgramSession::internal_stop_program(){
99102
WriteSpinLock lg(m_lock);
100-
// m_system.serial_session().stop();
103+
101104
CancellableScope* scope = m_scope.load(std::memory_order_acquire);
102105
if (scope != nullptr){
103106
scope->cancel(std::make_exception_ptr(ProgramCancelledException()));
@@ -107,8 +110,6 @@ void SingleSwitchProgramSession::internal_stop_program(){
107110
while (m_scope.load(std::memory_order_acquire) != nullptr){
108111
pause();
109112
}
110-
111-
// m_system.serial_session().reset();
112113
}
113114
void SingleSwitchProgramSession::internal_run_program(){
114115
GlobalSettings::instance().PERFORMANCE->REALTIME_THREAD_PRIORITY.set_on_this_thread();

SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_TurboMacro.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "NintendoSwitch/Options/TurboMacroTable.h"
99
#include "NintendoSwitch_TurboMacro.h"
1010

11+
//#include <iostream>
12+
//using std::cout;
13+
//using std::endl;
14+
1115
namespace PokemonAutomation{
1216
namespace NintendoSwitch{
1317

0 commit comments

Comments
 (0)