CACFLocalMessagePort::CACFLocalMessagePort(CFStringRef inName, CFMessagePortCallBack inPortCallBack, CFMessagePortInvalidationCallBack inInvalidationCallBack, void* inUserData) : mMessagePort(NULL), mRunLoopSource(NULL) { // create the CFMessagePort CFMessagePortContext theContext = { 0, inUserData, NULL, NULL, NULL }; mMessagePort = CFMessagePortCreateLocal(NULL, inName, inPortCallBack, &theContext, NULL); if(mMessagePort != NULL) { // add the invalidation callback, if any if(inInvalidationCallBack != NULL) { CFMessagePortSetInvalidationCallBack(mMessagePort, inInvalidationCallBack); } // get the run loop source mRunLoopSource = CFMessagePortCreateRunLoopSource(NULL, mMessagePort, NULL); if(mRunLoopSource == NULL) { CFRelease(mMessagePort); mMessagePort = NULL; DebugMessage("CACFLocalMessagePort::CACFLocalMessagePort: couldn't create the CFRunLoopSource"); throw CAException('what'); } } }
CACFRemoteMessagePort::CACFRemoteMessagePort(CFStringRef inName, CFMessagePortInvalidationCallBack inInvalidationCallBack) : mMessagePort(NULL), mRunLoopSource(NULL) { // create the CFMessagePort mMessagePort = CFMessagePortCreateRemote(NULL, inName); if(mMessagePort != NULL) { // failure to create a remote port does not need to throw an exception // because it isn't really an error since the port in question may not // exist and this fact requires a more complex response than an excpeption // provides for. // add the invalidation callback, if any if(inInvalidationCallBack != NULL) { CFMessagePortSetInvalidationCallBack(mMessagePort, inInvalidationCallBack); } // get the run loop source mRunLoopSource = CFMessagePortCreateRunLoopSource(NULL, mMessagePort, NULL); if(mRunLoopSource == NULL) { CFRelease(mMessagePort); mMessagePort = NULL; DebugMessage("CACFRemoteMessagePort::CACFRemoteMessagePort: couldn't create the CFRunLoopSource"); throw CAException('what'); } } }
CACFLocalMessagePort::CACFLocalMessagePort(CFStringRef inName, CFMessagePortCallBack inPortCallBack, CFMessagePortInvalidationCallBack inInvalidationCallBack, void* inUserData) : mMessagePort(NULL), mRunLoopSource(NULL), mDispatchQueue(NULL) { // create the CFMessagePort CFMessagePortContext theContext = { 0, inUserData, NULL, NULL, NULL }; mMessagePort = CFMessagePortCreateLocal(NULL, inName, inPortCallBack, &theContext, NULL); if(mMessagePort != NULL) { // add the invalidation callback, if any if(inInvalidationCallBack != NULL) { CFMessagePortSetInvalidationCallBack(mMessagePort, inInvalidationCallBack); } } }
CACFRemoteMessagePort::CACFRemoteMessagePort(CFStringRef inName, CFMessagePortInvalidationCallBack inInvalidationCallBack) : mMessagePort(NULL), mRunLoopSource(NULL), mDispatchQueue(NULL) { // create the CFMessagePort mMessagePort = CFMessagePortCreateRemote(NULL, inName); if(mMessagePort != NULL) { // failure to create a remote port does not need to throw an exception // because it isn't really an error since the port in question may not // exist and this fact requires a more complex response than an excpeption // provides for. // add the invalidation callback, if any if(inInvalidationCallBack != NULL) { CFMessagePortSetInvalidationCallBack(mMessagePort, inInvalidationCallBack); } } }