adium 4031:ae24b8d1c83a: Made the GCD-based event loop more cons...
commits at adium.im
commits at adium.im
Mon Jun 27 11:19:27 UTC 2011
details: http://hg.adium.im/adium/rev/ae24b8d1c83a
revision: 4031:ae24b8d1c83a
branch: (none)
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Mon Jun 27 13:19:17 2011 +0200
Made the GCD-based event loop more consistent. Improved logging of messages, distinguishing when something is really a bug and when it's just the callback canceling its own timer.
diffs (49 lines):
diff -r fb954d2dba9d -r ae24b8d1c83a Plugins/Purple Service/adiumPurpleEventloop.m
--- a/Plugins/Purple Service/adiumPurpleEventloop.m Mon Jun 27 11:50:27 2011 +0200
+++ b/Plugins/Purple Service/adiumPurpleEventloop.m Mon Jun 27 13:19:17 2011 +0200
@@ -36,10 +36,10 @@
gboolean adium_source_remove(guint tag) {
- NSValue *srcPointer = [sourceInfoDict objectForKey:[NSNumber numberWithInt:tag]];
+ NSValue *srcPointer = [sourceInfoDict objectForKey:[NSNumber numberWithUnsignedInt:tag]];
if (!srcPointer) {
- NSLog(@"Source info for %i not found in %@", tag, sourceInfoDict);
+ AILogWithSignature(@"Source info for %i not found in %@", tag, sourceInfoDict);
return FALSE;
}
@@ -47,7 +47,7 @@
dispatch_source_cancel(src);
dispatch_release(src);
- [sourceInfoDict removeObjectForKey:[NSNumber numberWithInt:tag]];
+ [sourceInfoDict removeObjectForKey:[NSNumber numberWithUnsignedInt:tag]];
return (dispatch_source_testcancel(src) != 0);
}
@@ -68,14 +68,20 @@
dispatch_source_set_timer(src, dispatch_time(DISPATCH_TIME_NOW, interval), interval, leeway);
+ [sourceInfoDict setObject:[NSValue valueWithPointer:src]
+ forKey:[NSNumber numberWithUnsignedInt:tag]];
+
dispatch_source_set_event_handler(src, ^{
+
+ if (![sourceInfoDict objectForKey:[NSNumber numberWithUnsignedInt:tag]]) {
+ AILogWithSignature(@"Timer with tag %i was already canceled!", tag);
+ return;
+ }
+
if (!function || !function(data))
adium_timeout_remove(tag);
});
- [sourceInfoDict setObject:[NSValue valueWithPointer:src]
- forKey:[NSNumber numberWithUnsignedInt:tag]];
-
dispatch_resume(src);
return tag;
More information about the commits
mailing list