Skip to content

Commit

Permalink
Merge branch 'remove-get-current-queue' of https://github.com/drodrig…
Browse files Browse the repository at this point in the history
…uez/XMPPFramework into drodriguez-remove-get-current-queue

Resolved Conflicts:
	Utilities/XMPPIDTracker.m
	Vendor/CocoaAsyncSocket/GCDAsyncSocket.h
	Vendor/CocoaAsyncSocket/GCDAsyncSocket.m
	Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m
	Vendor/CocoaLumberjack/DDFileLogger.m
	Vendor/CocoaLumberjack/DDLog.m
	Vendor/CocoaLumberjack/DDTTYLogger.m
  • Loading branch information
robbiehanson committed Apr 10, 2013
2 parents 8503cef + 2341cef commit b378ed5
Show file tree
Hide file tree
Showing 44 changed files with 370 additions and 317 deletions.
5 changes: 3 additions & 2 deletions Authentication/Anonymous/XMPPAnonymousAuthentication.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ - (BOOL)authenticateAnonymously:(NSError **)errPtr
result = NO;
}
}};

if (dispatch_get_current_queue() == self.xmppQueue)

const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_sync(self.xmppQueue, block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ - (BOOL)supportsDeprecatedDigestAuthentication
result = (digest != nil);
}
}};

if (dispatch_get_current_queue() == self.xmppQueue)

const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_sync(self.xmppQueue, block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ - (BOOL)supportsDeprecatedPlainAuthentication
result = (plain != nil);
}
}};

if (dispatch_get_current_queue() == self.xmppQueue)

const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_sync(self.xmppQueue, block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,9 @@ - (NSString *)facebookAppId
dispatch_block_t block = ^{
result = objc_getAssociatedObject(self, &facebookAppIdKey);
};

if (dispatch_get_current_queue() == self.xmppQueue)

const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_sync(self.xmppQueue, block);
Expand All @@ -269,7 +270,8 @@ - (void)setFacebookAppId:(NSString *)inFacebookAppId
objc_setAssociatedObject(self, &facebookAppIdKey, newFacebookAppId, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
};

if (dispatch_get_current_queue() == self.xmppQueue)
const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_async(self.xmppQueue, block);
Expand Down Expand Up @@ -313,8 +315,8 @@ - (BOOL)authenticateWithFacebookAccessToken:(NSString *)accessToken error:(NSErr
}
}};


if (dispatch_get_current_queue() == self.xmppQueue)
const char *xmppQueueTag = self.xmppQueueTag;
if (dispatch_get_specific(xmppQueueTag) == xmppQueueTag)
block();
else
dispatch_sync(self.xmppQueue, block);
Expand Down
1 change: 1 addition & 0 deletions Core/XMPPInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern NSString *const XMPPStreamDidChangeMyJIDNotification;
**/

@property (readonly) dispatch_queue_t xmppQueue;
@property (readonly) const char *xmppQueueTag;
@property (readonly) XMPPStreamState state;

/**
Expand Down
3 changes: 2 additions & 1 deletion Core/XMPPModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
@interface XMPPModule : NSObject
{
XMPPStream *xmppStream;

dispatch_queue_t moduleQueue;
const char* moduleQueueTag;
id multicastDelegate;
}

Expand Down
13 changes: 7 additions & 6 deletions Core/XMPPModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
#endif


@implementation XMPPModule

/**
Expand All @@ -31,6 +30,7 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
{
if ((self = [super init]))
{
moduleQueueTag = "moduleQueueTag";
if (queue)
{
moduleQueue = queue;
Expand All @@ -43,6 +43,7 @@ - (id)initWithDispatchQueue:(dispatch_queue_t)queue
const char *moduleQueueName = [[self moduleName] UTF8String];
moduleQueue = dispatch_queue_create(moduleQueueName, NULL);
}
dispatch_queue_set_specific(moduleQueue, moduleQueueTag, (void *)moduleQueueTag, NULL);

multicastDelegate = [[GCDMulticastDelegate alloc] init];
}
Expand Down Expand Up @@ -80,7 +81,7 @@ - (BOOL)activate:(XMPPStream *)aXmppStream
}
};

if (dispatch_get_current_queue() == moduleQueue)
if (dispatch_get_specific(moduleQueueTag) == moduleQueueTag)
block();
else
dispatch_sync(moduleQueue, block);
Expand Down Expand Up @@ -109,7 +110,7 @@ - (void)deactivate
}
};

if (dispatch_get_current_queue() == moduleQueue)
if (dispatch_get_specific(moduleQueueTag) == moduleQueueTag)
block();
else
dispatch_sync(moduleQueue, block);
Expand All @@ -122,7 +123,7 @@ - (dispatch_queue_t)moduleQueue

- (XMPPStream *)xmppStream
{
if (dispatch_get_current_queue() == moduleQueue)
if (dispatch_get_specific(moduleQueueTag) == moduleQueueTag)
{
return xmppStream;
}
Expand All @@ -146,7 +147,7 @@ - (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue
[multicastDelegate addDelegate:delegate delegateQueue:delegateQueue];
};

if (dispatch_get_current_queue() == moduleQueue)
if (dispatch_get_specific(moduleQueueTag) == moduleQueueTag)
block();
else
dispatch_async(moduleQueue, block);
Expand All @@ -158,7 +159,7 @@ - (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueu
[multicastDelegate removeDelegate:delegate delegateQueue:delegateQueue];
};

if (dispatch_get_current_queue() == moduleQueue)
if (dispatch_get_specific(moduleQueueTag) == moduleQueueTag)
block();
else if (synchronously)
dispatch_sync(moduleQueue, block);
Expand Down
12 changes: 7 additions & 5 deletions Core/XMPPParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define CHECK_FOR_NULL(value) \
do { \
if (value == NULL) { \
if (value == NULL) { \
xmpp_xmlAbortDueToMemoryShortage(ctxt); \
return; \
} \
Expand All @@ -30,7 +30,6 @@
static void xmpp_recursiveAddChild(NSXMLElement *parent, xmlNodePtr childNode);
#endif


@implementation XMPPParser
{
#if __has_feature(objc_arc_weak)
Expand All @@ -41,6 +40,7 @@ @implementation XMPPParser
dispatch_queue_t delegateQueue;

dispatch_queue_t parserQueue;
const char *xmppParserQueueTag;

BOOL hasReportedRoot;
unsigned depth;
Expand Down Expand Up @@ -703,7 +703,8 @@ - (id)initWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq parserQu
if (delegateQueue)
dispatch_retain(delegateQueue);
#endif


xmppParserQueueTag = "xmppParserQueueTag";
if (pq) {
parserQueue = pq;

Expand All @@ -714,6 +715,7 @@ - (id)initWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq parserQu
else {
parserQueue = dispatch_queue_create("xmpp.parser", NULL);
}
dispatch_queue_set_specific(parserQueue, xmppParserQueueTag, (void *)xmppParserQueueTag, NULL);

hasReportedRoot = NO;
depth = 0;
Expand Down Expand Up @@ -786,7 +788,7 @@ - (void)setDelegate:(id)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQ
delegateQueue = newDelegateQueue;
};

if (dispatch_get_current_queue() == parserQueue)
if (dispatch_get_specific(xmppParserQueueTag) == xmppParserQueueTag)
block();
else
dispatch_async(parserQueue, block);
Expand Down Expand Up @@ -840,7 +842,7 @@ - (void)parseData:(NSData *)data
}
}};

if (dispatch_get_current_queue() == parserQueue)
if (dispatch_get_specific(xmppParserQueueTag) == xmppParserQueueTag)
block();
else
dispatch_async(parserQueue, block);
Expand Down
Loading

0 comments on commit b378ed5

Please sign in to comment.