1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-08 10:52:58 +00:00

Attempt safe shutdown.

This commit is contained in:
Thomas Harte 2022-07-07 16:56:10 -04:00
parent 96189bde4b
commit 07ce0f0133
2 changed files with 18 additions and 6 deletions

View File

@ -62,10 +62,16 @@ template <typename Performer> class AsyncUpdater {
condition_.notify_all();
}
void stop() {
if(performer_thread_.joinable()) {
should_quit = true;
update([] {});
performer_thread_.join();
}
}
~AsyncUpdater() {
should_quit = true;
update([] {});
performer_thread_.join();
stop();
}
// The object that will actually receive time advances.

View File

@ -677,7 +677,6 @@ struct ActivityObserver: public Activity::Observer {
#pragma mark - Timer
- (void)audioQueueIsRunningDry:(nonnull CSAudioQueue *)audioQueue {
// TODO: Make audio flushes overt, and do one here.
updater.update([self] {
updater.performer.machine->flush_output();
});
@ -692,6 +691,8 @@ struct ActivityObserver: public Activity::Observer {
});
});
// TODO: restory sync locking; see below.
// First order of business: grab a timestamp.
/* const auto timeNow = Time::nanos_now();
@ -724,6 +725,10 @@ struct ActivityObserver: public Activity::Observer {
#define TICKS 120
- (void)start {
// _timer = [[CSHighPrecisionTimer alloc] initWithTask:^{
// updater.update([] {});
// } interval:uint64_t(1000000000) / uint64_t(TICKS)];
// updater.performer.machine = _machine->timed_machine();
/* __block auto lastTime = Time::nanos_now();
@ -805,8 +810,9 @@ struct ActivityObserver: public Activity::Observer {
#undef TICKS
- (void)stop {
[_timer invalidate];
_timer = nil;
updater.stop();
// [_timer invalidate];
// _timer = nil;
}
+ (BOOL)attemptInstallROM:(NSURL *)url {