logo
down
shadow

Why the main queue in iOS has to be a serial dispatch


Why the main queue in iOS has to be a serial dispatch

Content Index :

Why the main queue in iOS has to be a serial dispatch
Tag : objective-c , By : Yohan Lee
Date : November 28 2020, 09:01 AM

like below fixes the issue The purpose of the main queue is to provide a method for scheduling asynchronous work on the main thread. If the queue was concurrent, not all work would be done on the main thread, and that would make the queue useless.

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Is the main Grand Central Dispatch queue serial or concurrent?


Tag : development , By : mdiezb
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


Tag : ios , By : Kirks
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?


Tag : ios , By : Monev
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


Tag : ios , By : fukas78
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:

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.
Related Posts Related QUESTIONS :
  • Using a Swift extension method in Objective-C
  • How to convert HEXString (NSString) to ByteArray Objective-C
  • Cannot install Swift cocoapod without use_frameworks! module-swift.h file not found
  • shouldPerformSegueWithIdentifier always executed first
  • How to make a Swift enum available in Objective-C?
  • VSCode show `unrecognized token` for Objective-C header file
  • How to get data out of a block?
  • How to fix Zombie Object throwing 'EXC_BAD_INSTRUCTION' when calling show window
  • How to keep checking a value until it changes without using infinite loop?
  • (Objective-C++) Testing float value causes infinite loop
  • Use of macro with condition in swift
  • How to stop sending requests to dispatch_async requests for ringing?
  • Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'
  • Diffable data source for TableView error on iOS 13: Inconsistent associations for moves
  • Objective C: How to get access token from web browser to cocoa app?
  • App crashes while converting to Objective-C ARC
  • When updating the TestFlight SDK do you need to delete the old version?
  • Issue overriding the default constructor of the UIButton Class?
  • NSData to NSArray of UInt16 in Objective C
  • How to read file by sector,and not rely on the OS cache in Cocoa
  • Why doesn't strlen() return the correct number of bytes here?
  • AWS API Gateway unreliability in refresh
  • Sending dictionary from a VC to another VC through Custom delegtes
  • Convert from NStimeInterval to CMTime accurately
  • How can I continue my count from the correct spot once I load the saved count?
  • instance method 'connect:' not found (return type defaults to 'id'
  • Does an object initialize automatically if it is the synthesized property of another object?
  • Algorithm to group consecutive words minimizing length per group
  • Unable to add UIScrollView to UITableView
  • What reasons are there to pass an argument to an initializer in objective C?
  • NSLogging UILabel's text outputs null
  • undefined reference to '__objc_class_name_Fraction'
  • NSOutlineview with checkbox
  • Accessing Property from another NSObjectClass
  • Implementing background worker - Obj C/Cocoa
  • Move UIView above UITableView when user Scrolls Down
  • Getting warning assigning a const void * to a char * array
  • adding object to nsmutablearray with custom delegate function giving error
  • Cocoa editing NSBezierPath
  • How to set custom title letters spacing for UINavigationBar in Objective-C
  • Can't access CCNode as child of scene
  • load local json information in UITableView
  • how to convert date and time string to date string?
  • NSButton rendering issues when displayed over NSImageView
  • NSComboBox to display duplicate items in different colors
  • How to set transparency of translucent navigation bar in iOS7?
  • Return 1 in objective-c
  • UIPAGEVIEWCONTROLLER Datasource methods called Twice on Fast Swipe
  • NSMutableData allocation performance
  • Does anything in Objective-C use associative references under the hood?
  • Perform a action on specific time using Parse
  • Objective-C: How to convert json value to BOOL?
  • How to make an int counter for the days
  • Assigning Label Value with Selected Table View Cell
  • SpriteKit - Preloader using GCD
  • Can dependency injection like Typhoon replace multiple singletons?
  • Objective C - How to determine if a folder is a package?
  • How can one draw a background in the elastic portion of an NSScrollView?
  • A solution for my issue with sending some info from an array to Parse
  • Swift Extension fails adding overloaded methods to Objective-C class
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com