Skip to content
Browse files

Revert "Woo, GCD! Removing locks from the receiver patch"

GCD seems to create horrible latency sometimes - up to 5 seconds between dispatch_async & actually running the block
This reverts commit 55c6264.
  • Loading branch information...
1 parent 71581cb commit 562836b7b24c1ba93ce612f3b35d61207cc3244f Jonathan del Strother committed Sep 16, 2009
Showing with 10 additions and 4 deletions.
  1. +1 −4 BBOSCInPort.m
  2. +1 −0 BBOSCPluginReceiver.h
  3. +8 −0 BBOSCPluginReceiver.m
View
5 BBOSCInPort.m
@@ -47,9 +47,6 @@ -(void)remove {
}
- (void) receivedOSCMessage:(OSCMessage *)m {
- // Bounce off to the main thread so plugins don't have to worry about locking
- dispatch_async(dispatch_get_main_queue(), ^{
- [delegates makeObjectsPerformSelector:@selector(receivedOSCMessage:) withObject:m];
- });
+ [delegates makeObjectsPerformSelector:@selector(receivedOSCMessage:) withObject:m];
}
@end
View
1 BBOSCPluginReceiver.h
@@ -11,6 +11,7 @@
@class BBOSCInPort;
@interface BBOSCPluginReceiver : QCPlugIn {
NSMutableArray* messages;
+ NSLock* messageLock;
}
@property (nonatomic, readonly, retain) NSString* listeningPath;
@property (nonatomic, readonly, retain) NSArray* oscParameters;
View
8 BBOSCPluginReceiver.m
@@ -91,6 +91,7 @@ - (id) init
if(self = [super init]) {
self.oscParameters = [NSArray array];
messages = [[NSMutableArray alloc] init];
+ messageLock = [[NSLock alloc] init];
listeningPath = @"";
}
@@ -110,6 +111,7 @@ - (void) dealloc
{
[oscPort release];
[messages release];
+ [messageLock release];
[listeningPath release];
[oscParameters release];
[retryTime release];
@@ -151,9 +153,11 @@ -(void)setOscParameters:(NSArray*)params {
- (void) receivedOSCMessage:(OSCMessage *)m {
+ [messageLock lock];
if ([[m address] hasPrefix:self.listeningPath]) {
[messages addObject:m];
}
+ [messageLock unlock];
}
@end
@@ -187,8 +191,10 @@ Return NO in case of failure during the execution (this will prevent rendering o
*/
if ([self didValueForInputKeyChange:@"inputReceivingPath"]) {
+ [messageLock lock];
self.listeningPath = self.inputReceivingPath;
[messages removeAllObjects];
+ [messageLock unlock];
}
if ([self didValueForInputKeyChange:@"inputReceivingPort"]||[self didValueForInputKeyChange:@"inputLabel"] || (self.retryTime && [self.retryTime timeIntervalSinceNow]<0)) {
@@ -215,6 +221,7 @@ Return NO in case of failure during the execution (this will prevent rendering o
}
}
+ [messageLock lock];
if ([messages count]==0) {
self.outputMessageReceived = NO;
} else {
@@ -244,6 +251,7 @@ Return NO in case of failure during the execution (this will prevent rendering o
else
[messages removeObjectAtIndex:0];
}
+ [messageLock unlock];
return YES;
}

0 comments on commit 562836b

Please sign in to comment.
Something went wrong with that request. Please try again.