Is the main Grand Central Dispatch queue serial or concurrent?
Date : March 29 2020, 07:55 AM
this will help Suppose I call dispatch_async() three times in order: , From the documentation:
|
What happens to main queue/main thread, when a dispatch_sync is issued from main thread targeting another dispatch queue
Date : March 29 2020, 07:55 AM
I wish this help you It doesn't matter whether it's the main queue or not. Whatever queue is used to call objectAtIndex: will block on the dispatch_sync call until it completes. If you call this code on the main queue, it blocks like any other queue. During that time, no user events will be processed. The UI will appear locked during that time. When done, the UI will again work as normal.
|
How does a serial queue/private dispatch queue know when a task is complete?
Date : March 29 2020, 07:55 AM
this one helps. The serialisation of work on a serial dispatch queue is at the unit of work that is directly submitted to the queue. Once execution reaches the end of the submitted closure (or it returns) then the next unit of work on the queue can be executed. Importantly, any other asynchronous tasks that may have been started by the closure may still be running (or may not have even started running yet), but they are not considered. dispatch_async(serialQueue) {
print("Start")
dispatch_async(backgroundQueue) {
functionThatTakes10Seconds()
print("10 seconds later")
}
print("Done 1st")
}
dispatch_async(serialQueue) {
print("Start")
dispatch_async(backgroundQueue) {
functionThatTakes10Seconds()
print("10 seconds later")
}
print("Done 2nd")
}
dispatch_async(serialQueue) {
print("Start")
dispatch_sync(backgroundQueue) {
functionThatTakes10Seconds()
print("10 seconds later")
}
print("Done 1st")
}
dispatch_async(serialQueue) {
print("Start")
dispatch_sync(backgroundQueue) {
functionThatTakes10Seconds()
print("10 seconds later")
}
print("Done 2nd")
}
dispatch_async(serialQueue) {
let dg = dispatch_group_create()
dispatch_group_enter(dg)
print("Start")
dispatch_async(backgroundQueue) {
functionThatTakes10Seconds()
print("10 seconds later")
dispatch_group_leave(dg)
}
dispatch_group_wait(dg)
print("Done")
}
|
Dispatch Group Serial Queue
Date : March 29 2020, 07:55 AM
Any of those help There's no such thing as a "serial dispatch group". Serial/concurrent is a property of a queue, not of a group. Given that AVAssetExportSession is, itself, an asynchronous process, simple attempts to add it to a serial queue will not work. Two approaches seem logical. You can either:
|
dispatch sync vs dispatch async in main queue ios related query
Tag : ios , By : Pradeep Gowda
Date : September 12 2020, 05:00 AM
This might help you When you, a queue, say DispatchQueue.main.sync or DispatchQueue.main.async, that does not affect how the main queue behaves; it affects how you behave, ie whether you wait before doing what comes after the call. But you have nothing after the call so there is no distinction to draw. Your “test” does not test anything.
|