From 5bca70d1418fc5403f575dc43952f09119bca5f6 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 15 Jun 2022 01:10:53 -0700 Subject: [PATCH] [Job Queue] Prevent multiple jobs from stacking Jobs are meant to be serialized, so prevent multiple jobs from queueing simultaneously, as they are not designed to interact with each other. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistController.m | 3 +++ Playlist/PlaylistLoader.m | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 08c0de4d5..91901a94b 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -219,6 +219,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc } - (void)beginProgress:(NSString *)localizedDescription { + while(playbackController.progressOverall) { + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]]; + } dispatch_sync_reentrant(dispatch_get_main_queue(), ^{ self->playbackController.progressOverall = [NSProgress progressWithTotalUnitCount:100000]; self->playbackController.progressOverall.localizedDescription = localizedDescription; diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index e42a262da..76cb6278d 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -262,6 +262,9 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc } - (void)beginProgress:(NSString *)localizedDescription { + while(playbackController.progressOverall) { + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]]; + } dispatch_sync_reentrant(dispatch_get_main_queue(), ^{ self->playbackController.progressOverall = [NSProgress progressWithTotalUnitCount:100000]; self->playbackController.progressOverall.localizedDescription = localizedDescription;