Skip to content

Commit e359e02

Browse files
committed
Add main thread work execution to app loop
Invoke WorkService::executeMainThreadWork and delegate's applicationMainLoop in the main application loop. This allows services and the app delegate to perform main-thread-specific tasks during each iteration.
1 parent 2f7bd25 commit e359e02

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/Core/EntropyApplication.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ int EntropyApplication::run() {
118118
// Continue waiting afterwards
119119
continue;
120120
}
121+
122+
// Run the main thread work service jobs.
123+
_services.get<Concurrency::WorkService>()->executeMainThreadWork();
124+
125+
// Let the app delegate execute its main thread work.
126+
if (_delegate) _delegate->applicationMainLoop();
121127
}
122128
}
123129
}
@@ -145,6 +151,12 @@ int EntropyApplication::run() {
145151
int signum = _lastSignal.load(std::memory_order_relaxed);
146152
handlePosixSignal(signum);
147153
}
154+
155+
// Run the main thread work service jobs.
156+
_services.get<Concurrency::WorkService>()->executeMainThreadWork();
157+
158+
// Let the app delegate execute its main thread work.
159+
if (_delegate) _delegate->applicationMainLoop();
148160
}
149161
} else {
150162
// Fallback to condition_variable if signal handlers not installed

src/Core/EntropyApplication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class EntropyAppDelegate {
3434
virtual bool applicationShouldTerminate() { return true; }
3535
virtual void applicationWillTerminate() {}
3636
virtual void applicationDidCatchUnhandledException(std::exception_ptr) {}
37+
virtual void applicationMainLoop() {}
3738
};
3839

3940
struct EntropyApplicationConfig {

0 commit comments

Comments
 (0)