File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -436,19 +436,16 @@ extension OperatingMode {
436436 task ( )
437437 }
438438 case . server:
439- // if .main is used, we'll get a lockup calling sync.
440- // so instead, we're gonna use a worker, as our Dispatch
441- // mechanisms only work when a queue is in place. Just
442- // calling the task() wouldn't be enough.
443- if queue == DispatchQueue . main {
444- DispatchQueue . global ( qos: . utility) . sync {
445- task ( )
446- }
447- } else {
448- queue. sync {
449- task ( )
450- }
439+ // we need to be careful about doing a sync on the same queue we're running
440+ // on, and we have no way of knowing that. So we're gonna dispatch to a
441+ // safe place elsewhere, and just wait.
442+ let group = DispatchGroup ( )
443+ group. enter ( )
444+ DispatchQueue . global ( qos: . utility) . async {
445+ task ( )
446+ group. leave ( )
451447 }
448+ group. wait ( )
452449 }
453450 }
454451}
You can’t perform that action at this time.
0 commit comments