Пример #1
0
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');
		}
	}
}
Пример #2
0
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');
		}
	}
}
Пример #3
0
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);
		}
	}
}
Пример #4
0
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);
		}
	}
}