Re: [2/3 solved] CFMessage woe
Re: [2/3 solved] CFMessage woe
- Subject: Re: [2/3 solved] CFMessage woe
- From: Dave Keck <email@hidden>
- Date: Thu, 4 Mar 2010 02:10:04 -1000
> Yes, but as far as I can't use the CFRef I got, I'd consider it a bug.
Not quite. CFMessagePortSendRequest()'s data argument isn't interested
in the pointer itself, it's interested in the data that lies at that
pointer. This is so because Mach ports' primary use is IPC between
different processes, not between threads.
You could of course wrap a pointer in a data object:
void *myPointer = 0xFEEDFACE;
CFDataRef data = CFDataCreate(NULL, &myPointer, sizeof(myPointer));
CFMessagePortSendRequest(...);
Meanwhile, on the receiving end:
void *receivedPointer = NULL;
CFDataGetBytes(receivedData, CFRangeMake(0,
sizeof(receivedPointer)), &receivedPointer);
And after receiving the message, receivedPointer == the original myPointer.
Some other thoughts:
1. I'm having a hard time understanding exactly what you want to do;
it'd help if you could explain from a high-level what your goal is.
2. Is there a reason you can't link Foundation? It will make your life
much easier; you could send your pointer to another thread in a single
line and avoid the CFMessage APIs altogether.
3. You would get a lot more useful feedback if this were on Cocoa dev. :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden