Re: NSImage from bitmap - then delete bitmap
Re: NSImage from bitmap - then delete bitmap
- Subject: Re: NSImage from bitmap - then delete bitmap
- From: Ken Thomases <email@hidden>
- Date: Sat, 23 Jul 2016 01:09:38 -0500
On Jul 22, 2016, at 9:29 PM, Graham Cox <email@hidden> wrote:
>
>
>> On 23 Jul 2016, at 12:45 AM, Trygve Inda <email@hidden> wrote:
>>
>> Because the main thread sometimes needs to ask the worker threads to
>> terminate. If it does this after performOnMainThread has been called by a
>> worker thread, but before the main thread has processed it, then the main
>> thread will block waiting for the worker thread to exit, but the worker
>> thread has already blocked when it called performOnMainThread.
>>
>> Very rare, but it can happen.
>
> This is wrong thinking.
>
> If the worker thread is waiting for -performOnMainThread to complete, it *cannot* possibly get a call from the main thread to terminate, because the main thread is dealing with whatever the other thread asked it to do.
No, because the main thread may not have started servicing the performSelector request yet. The background thread has blocked as soon as the request is _queued_ for the main thread, not just once the main thread has received the request. If the main thread makes a synchronous request to the background thread before it gets back to the run loop to service the pending performSelector request, it will deadlock.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden