-
Notifications
You must be signed in to change notification settings - Fork 435
fix: make runUntilDate not system aware #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f86edc7
8826443
cbad468
43adc5a
c9bf35a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSRunLoop (Monotonic) | ||
/** | ||
Runs the current run loop in the default mode for the specified monotonic time interval. | ||
|
||
This method uses a monotonic clock to ensure the interval is not affected | ||
by changes to the system clock. The run loop will repeatedly process events | ||
until the given number of seconds has elapsed. | ||
|
||
@param seconds The duration, in seconds, to run the run loop. | ||
*/ | ||
- (void)runForMonotonicInterval:(NSTimeInterval)seconds; | ||
KazuCocoa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||
#import "NSRunLoop+Monotonic.h" | ||||||
#import <QuartzCore/QuartzCore.h> | ||||||
|
||||||
@implementation NSRunLoop (Monotonic) | ||||||
|
||||||
- (void)runForMonotonicInterval:(NSTimeInterval)seconds { | ||||||
CFTimeInterval end = CACurrentMediaTime() + seconds; | ||||||
while (CACurrentMediaTime() < end) { | ||||||
[self runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can your issue be resolved with:
Suggested change
It looks like the default mode could block some actions such as UI tracking. I observed this blocking behavior in https://stackoverflow.com/questions/7222449/nsdefaultrunloopmode-vs-nsrunloopcommonmodes |
||||||
} | ||||||
} | ||||||
|
||||||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a docstring to the public interface method?