Reputation: 310
With Obj-C method invocations are implemented with messages, thus, an object receive a message and if having the corresponding selector for that message it execute the method on the object instance.
Having that said, is there any kind of queue where messages are queued on the process? is this a serial queue or concurrent queue? does this queue guarantee thread safety ( eg. SingleThreaded apartment )
Upvotes: 0
Views: 186
Reputation: 71008
"Messages" is the conceptual understanding of method calls in ObjC; in practice it's just a dynamic dispatch mechanism. The call still happens and returns synchronously on the thread that you make it from.
ObjC messaging doesn't work like a per-thread message pump like, e.g. Windows messages which it sounds like you may be thinking of. There are ways of doing IPC, and of course ways of setting up serial or concurrent queued work on background threads (see Grand Central Dispatch), but neither of these have to do with the actual ObjC messaging dispatch mechanism for method calls.
(You may see some cross-thread stuff in Cocoa tied to a Cocoa-native concept called the "run loop", and if you use NSObject's -performSelector...
methods to invoke things on other threads, that will use the run loop to schedule those invocations, and guarantee ordering. But that's a higher-order concept than the "messages" themselves.)
Upvotes: 3