Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dispatch_retain & dispatch_release no longer needed with latest ARC

  • Loading branch information...
commit f7129a7aae89b445d97285cb0dcbf230de2ecec1 1 parent a82260a
@robbiehanson authored
View
46 Core/HTTPConnection.m
@@ -16,6 +16,31 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+// Does ARC support support GCD objects?
+// It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
@@ -182,7 +207,9 @@ - (id)initWithAsyncSocket:(GCDAsyncSocket *)newSocket configuration:(HTTPConfig
if (aConfig.queue)
{
connectionQueue = aConfig.queue;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_retain(connectionQueue);
+ #endif
}
else
{
@@ -218,21 +245,17 @@ - (void)dealloc
{
HTTPLogTrace();
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(connectionQueue);
+ #endif
[asyncSocket setDelegate:nil delegateQueue:NULL];
[asyncSocket disconnect];
-
-
-
if ([httpResponse respondsToSelector:@selector(connectionDidClose)])
{
[httpResponse connectionDidClose];
}
-
-
-
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2686,8 +2709,10 @@ - (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoo
if (q)
{
- dispatch_retain(q);
queue = q;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
+ dispatch_retain(queue);
+ #endif
}
}
return self;
@@ -2695,10 +2720,9 @@ - (id)initWithServer:(HTTPServer *)aServer documentRoot:(NSString *)aDocumentRoo
- (void)dealloc
{
-
- if (queue)
- dispatch_release(queue);
-
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
+ if (queue) dispatch_release(queue);
+ #endif
}
@end
View
31 Core/HTTPServer.m
@@ -8,6 +8,31 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+// Does ARC support support GCD objects?
+// It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_INFO; // | HTTP_LOG_FLAG_TRACE;
@@ -104,14 +129,12 @@ - (void)dealloc
// Release all instance variables
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(serverQueue);
dispatch_release(connectionQueue);
+ #endif
[asyncSocket setDelegate:nil delegateQueue:NULL];
-
-
-
-
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
View
37 Core/Responses/HTTPAsyncFileResponse.m
@@ -9,6 +9,32 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+/**
+ * Does ARC support support GCD objects?
+ * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+**/
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels : off, error, warn, info, verbose
// Other flags: trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
@@ -232,7 +258,9 @@ - (BOOL)openFileAndSetupReadSource
});
int theFileFD = fileFD;
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_source_t theReadSource = readSource;
+ #endif
dispatch_source_set_cancel_handler(readSource, ^{
@@ -242,7 +270,9 @@ - (BOOL)openFileAndSetupReadSource
HTTPLogTrace2(@"%@: cancelBlock - Close fd[%i]", THIS_FILE, theFileFD);
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(theReadSource);
+ #endif
close(theFileFD);
});
@@ -390,13 +420,12 @@ - (void)dealloc
{
HTTPLogTrace();
- if (readQueue)
- dispatch_release(readQueue);
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
+ if (readQueue) dispatch_release(readQueue);
+ #endif
if (readBuffer)
free(readBuffer);
-
-
}
@end
View
29 Core/WebSocket.m
@@ -9,6 +9,31 @@
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif
+// Does ARC support support GCD objects?
+// It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
+
+#if TARGET_OS_IPHONE
+
+ // Compiling for iOS
+
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else // iOS 5.X or earlier
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1
+ #endif
+
+#else
+
+ // Compiling for Mac OS X
+
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 0
+ #else
+ #define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
+ #endif
+
+#endif
+
// Log levels: off, error, warn, info, verbose
// Other flags : trace
static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
@@ -193,12 +218,12 @@ - (void)dealloc
{
HTTPLogTrace();
+ #if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(websocketQueue);
-
+ #endif
[asyncSocket setDelegate:nil delegateQueue:NULL];
[asyncSocket disconnect];
-
}
- (id)delegate
Please sign in to comment.
Something went wrong with that request. Please try again.