Re: How is my CFRunLoopTimer getting called during a CFReadStream client callback?
Re: How is my CFRunLoopTimer getting called during a CFReadStream client callback?
- Subject: Re: How is my CFRunLoopTimer getting called during a CFReadStream client callback?
- From: Jens Alfke <email@hidden>
- Date: Sun, 05 Jan 2014 18:29:37 -0800
On Jan 5, 2014, at 4:37 PM, Jim O'Connor <email@hidden> wrote:
> When my read stream finishes I schedule a timer to clean up on the runloop to serialize access to shared resources.
> However, I had a hang late last night because a mutex grabbed in the read stream callback handler was held and was also being grabbed when the timer it scheduled to clean up fired INSIDE the callback.
If your stream and timer are scheduled on the same runloop, they’ll never run on different threads.
However, it’s possible for a runloop to run re-entrantly — that is, if you call something that blocks and runs the runloop, your callback (a timer or whatever) might get invoked inside there. So you might get a stack like
runloop —> my stream callback —> some system API —> runloop —> my timer callback
Make sure to save the stack next time this happens.
—Jens
_______________________________________________
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