[MacRuby] #1491: Dispatch::Source.timer should not repeat if specify TIME_FOREVER to interval.
MacRuby
ruby-noreply at macosforge.org
Fri Mar 30 17:35:53 PDT 2012
#1491: Dispatch::Source.timer should not repeat if specify TIME_FOREVER to
interval.
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
Test Script:
{{{
gcdq = Dispatch::Queue.new('sample')
timer = Dispatch::Source.timer(1, Dispatch::TIME_FOREVER, 0, gcdq) do |s|
puts "Wake up!"
end
sleep 3
}}}
Result:
{{{
$ macruby gcd.rb
Wake up!
Wake up!
Wake up!
Wake up!
---- snip ----
}}}
I wrote same code with Objective-C, and it does not repeat.
{{{
#import <Foundation/Foundation.h>
int main(void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
dispatch_queue_t queue = dispatch_queue_create("sample", NULL);
dispatch_source_t timer =
dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(timer,
dispatch_time(DISPATCH_TIME_NOW, 1ull *
NSEC_PER_SEC),
DISPATCH_TIME_FOREVER,
0);
dispatch_source_set_event_handler(timer, ^{
NSLog(@"Wake up");
});
dispatch_resume(timer);
sleep(3);
[pool release];
return 0;
}
}}}
{{{
$ gcc gcd.m -framework Foundation
$ ./a.out
2012-03-31 09:33:59.188 a.out[61445:1703] Wake up
$
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/1491>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list