discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does method invocation involve a lock?


From: Richard Frith-Macdonald
Subject: Re: does method invocation involve a lock?
Date: Fri, 21 Sep 2018 16:18:56 +0100

> On 21 Sep 2018, at 15:49, Tom Sheffler <tom.sheffler@gmail.com> wrote:
> 
> This question is for my own research: I’m curious about whether invoking [obj 
> method] can block.  If obj is allocated, and method is simple, does method 
> invocation involve a lock.
> 
> I think the answer is YES.  But I looked at the source code for objc_msgSend 
> and didn’t see anything that looked like it acquired a lock.

The answer is usually NO, but the first time you send any method to a class the 
+initialize method of that class is implicitly called, and that operation is 
implicitly lock protected.  If you are worried about that, the simple solution 
is to make sure that classes you are concerned about are initialised at the 
start of your program (eg by calling the +class method) , so that code 
executing later can be confident that there won't be unexpected blocking.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]