summaryrefslogtreecommitdiff
path: root/frontends/cocoa/schedule.m
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/cocoa/schedule.m')
-rw-r--r--frontends/cocoa/schedule.m68
1 files changed, 35 insertions, 33 deletions
diff --git a/frontends/cocoa/schedule.m b/frontends/cocoa/schedule.m
index 65ca7f15d..0fc55efbd 100644
--- a/frontends/cocoa/schedule.m
+++ b/frontends/cocoa/schedule.m
@@ -23,55 +23,57 @@
#import "cocoa/schedule.h"
@interface ScheduledCallback : NSObject {
- void (*callback)( void *userData );
- void *userData;
+ void (*callback)(void *userData);
+ void *userData;
}
-- (instancetype)initWithCallback: (void (*)(void *))cb userData: (void *)ud;
-- (void) schedule: (NSTimeInterval) ti;
+- (instancetype)initWithCallback:(void (*)(void *))cb userData:(void *)ud;
+- (void)schedule:(NSTimeInterval)ti;
@end
@implementation ScheduledCallback
-- (instancetype)initWithCallback: (void (*)(void *))cb userData: (void *)ud
+- (instancetype)initWithCallback:(void (*)(void *))cb userData:(void *)ud
{
- callback = cb;
- userData = ud;
-
- return self;
+ callback = cb;
+ userData = ud;
+
+ return self;
}
static NSMutableSet *timerSet = nil;
-- (void) schedule: (NSTimeInterval) ti
+- (void)schedule:(NSTimeInterval)ti
{
- if (nil == timerSet) {
- timerSet = [[NSMutableSet alloc] init];
- }
-
- [self performSelector: @selector(timerFired) withObject: nil afterDelay: ti];
- [timerSet addObject: self];
+ if (nil == timerSet) {
+ timerSet = [[NSMutableSet alloc] init];
+ }
+
+ [self performSelector:@selector(timerFired) withObject:nil afterDelay:ti];
+ [timerSet addObject:self];
}
-- (void) timerFired
+- (void)timerFired
{
- if ([timerSet containsObject: self]) {
- [timerSet removeObject: self];
- callback( userData );
- }
+ if ([timerSet containsObject:self]) {
+ [timerSet removeObject:self];
+ callback(userData);
+ }
}
-- (BOOL) isEqual: (id)object
+- (BOOL)isEqual:(id)object
{
- if (object == self) return YES;
- if ([object class] != [self class]) return NO;
- return ((ScheduledCallback *)object)->callback == callback && ((ScheduledCallback *)object)->userData == userData;
+ if (object == self)
+ return YES;
+ if ([object class] != [self class])
+ return NO;
+ return ((ScheduledCallback *)object)->callback == callback && ((ScheduledCallback *)object)->userData == userData;
}
-- (NSUInteger) hash
+- (NSUInteger)hash
{
- return (NSUInteger)callback + (NSUInteger)userData;
+ return (NSUInteger)callback + (NSUInteger)userData;
}
@end
@@ -79,11 +81,11 @@ static NSMutableSet *timerSet = nil;
/* exported interface documented in cocoa/schedule.h */
nserror cocoa_schedule(int t, void (*callback)(void *p), void *p)
{
- ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
- [timerSet removeObject: cb];
- if (t >= 0) {
- [cb schedule: (NSTimeInterval)t / 1000];
- }
+ ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback:callback userData:p];
+ [timerSet removeObject:cb];
+ if (t >= 0) {
+ [cb schedule:(NSTimeInterval)t / 1000];
+ }
- return NSERROR_OK;
+ return NSERROR_OK;
}