CPMIGServerSource

From iPhone Development Wiki
Revision as of 20:15, 20 October 2009 by KennyTM~ (talk | contribs) (Created page with 'CPMIGServerSource is a CF class that creates a convenient function to hook a MIG-generated subsystem to a run loop. == Example code == <source lang="c"> #include <GraphicsSe…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CPMIGServerSource is a CF class that creates a convenient function to hook a MIG-generated subsystem to a run loop.

Example code

#include <GraphicsServices/GSEvent.h>
#include <AppSupport/CPMIGServerSource.h>
#include <CoreFoundation/CoreFoundation.h>
#include <mach/mach.h>
#include "myMIGSubsys.h"

extern struct mig_subsystem myMIGSubsys_subsystem;

...

	mach_port_t port = GSRegisterPurpleNamedPort("com.yourcompany.myMIGSubsys");
	struct mach_port_limits queueSize = {16};
	kern_return_t err = mach_port_set_attributes(mach_task_self(), port, MACH_PORT_LIMITS_INFO, &queueSize, 1);
	if (err) {
		CFLog(kCFLogLevelWarning, CFSTR("Cannot set queue size: %s\n"), mach_error_string(err));
	}
	CPMIGServerSourceRef source = CPCreateMIGServerSource(&myMIGSubsys_subsystem, port, 0);
	CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
	CFRelease(source);

...

Header