• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get the dispatch queue for the current thread's runloop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the dispatch queue for the current thread's runloop?


  • Subject: Re: How to get the dispatch queue for the current thread's runloop?
  • From: Dave Keck <email@hidden>
  • Date: Fri, 27 Jan 2012 19:43:03 -0500

Hi Jens,

My understanding is that dispatch queues are tied to threads that are
managed by the system and are separate from run loops. It's therefore
non-sensical to ask for a runloop's queue.

Regardless though, I think a better solution for you is a category on
NSTimer. I use something like the following:

====================
@implementation NSTimer (BlockTimersYay)
+ (NSTimer *)scheduledTimerWithTimeInterval:
(NSTimeInterval)timeInterval repeats: (BOOL)repeats block: (void
(^)(void))block
{
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:
timeInterval target: self selector: @selector(fireBlockTimer:)
userInfo: [[block copy] autorelease] repeats: repeats];
    [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes];
    return timer;
}
+ (void)fireBlockTimer: (NSTimer *)blockTimer
{
    ((void (^)(void))[blockTimer userInfo])();
}
@end
====================

Note that this is slightly different than NSTimer in that the timer is
added to the common modes rather than the default mode.
_______________________________________________

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


References: 
 >How to get the dispatch queue for the current thread's runloop? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to get the dispatch queue for the current thread's runloop?
  • Next by Date: Re: How to get the dispatch queue for the current thread's runloop?
  • Previous by thread: Re: How to get the dispatch queue for the current thread's runloop?
  • Next by thread: Re: How to get the dispatch queue for the current thread's runloop?
  • Index(es):
    • Date
    • Thread