I have been spending the weekend disecting code from WSMakeStubs and getting into the depths of the WebServices framework, and I'm having some trouble understanding a section of code.
When you use WSMakeStubs, it generates a pretty standard template object (WSGeneratedObj) which has within it a getResultsDictionary method. Prior to it's getting to this method, it's established the WSMethodInvocationRef with an asynchronous callback. So far, I'm all with this plan of attack. Then we get into this method:
The method in question:
- (NSDictionary*) getResultDictionary {
if (fResult == NULL) { if (fAsyncTarget != NULL) { fAsyncTarget = NULL; fAsyncSelector = NULL; }
if (fResult == NULL) { WSMethodInvocationRef invocation = [self getRef]; CFStringRef wsGeneratedMode = CFSTR("NS-WSSYNC");
WSMethodInvocationScheduleWithRunLoop(invocation, CFRunLoopGetCurrent(), wsGeneratedMode);
while (fResult == NULL) CFRunLoopRunInMode(wsGeneratedMode, -1.0, true);
WSMethodInvocationUnscheduleFromRunLoop(invocation, CFRunLoopGetCurrent(), wsGeneratedMode);
}
if (fResult == NULL) { [self handleError:@"WSMethodInvocationInvoke failed in getResultDictionary" errorString:NULL errorDomain:kCFStreamErrorDomainMacOSStatus errorNumber:paramErr]; } } return fResult; }
What I don't understand is the call to CFRunLoopRunInMode. The documentation on CFRunLoopRunInMode talks about running a runloop for 0 seconds, and > 0 seconds, but doesn't say anything about < 0 seconds.
Is this method call a mechanism to guarantee that the scheduled invocation will get called and when this method returns it will have definitively been invoked?
-joe |