ios - Serializable dispatch queue create -


i need create serializable dispatch queue.

i'm using audiounit register microphone, , encoding frame on created queue. have 1 object encoding, need same thread accessing it.

however, when create queue :

queue = dispatch_queue_create("com.myapp.queue", dispatch_queue_serial); 

if dispatch queue :

nslog(@"recording callback thread info: %@", [nsthread currentthread]); dispatch_async(queue, ^{     [self processaudio]; });  - (void) processaudio {     nslog(@"processaudio thread info: %@", [nsthread currentthread]); ... } 

it using same thread until 1 point :

recording callback thread info: <nsthread: 0x7fb0ab331b90>{number = 12, name = (null)} processaudio thread info: <nsthread: 0x7fb0ab210140>{number = 7, name = (null)}  recording callback thread info: <nsthread: 0x7fb0ab331b90>{number = 12, name = (null)} processaudio thread info: <nsthread: 0x7fb0a8e33950>{number = 8, name = (null)}  recording callback thread info: <nsthread: 0x7fb0ab331b90>{number = 12, name = (null)} processaudio thread info: <nsthread: 0x7fb0ab212bf0>{number = 13, name = (null)} 

the dispatch_async switch thread, , stick while thread number 13, until switch again.

is normal behavior although specified wanted serial queue ? should worried switching thread, when using 1 instance of object, or serialized ?

this expected behavior , should not worry it. apple's docs (https://developer.apple.com/library/ios/documentation/general/conceptual/concurrencyprogrammingguide/operationqueues/operationqueues.html):

serial queues (also known private dispatch queues) execute 1 task @ time in order in added queue. executing task runs on distinct thread (which can vary task task) managed dispatch queue.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -