Thanks for your reply. I guess then I'll use CFMessagePort, since I
would not have to use mach API calls.
Not to complain, but is there any official documentation for the mach
API anywhere? Not including header files or source. Or is this Apple's
way of discouraging people from using it?
thanks,
Philip Lukidis
> -----Original Message-----
> From: Herb Petschauer [mailto:email@hidden]
> Sent: Friday, November 18, 2005 2:40 PM
> To: Philip Lukidis
> Cc: email@hidden
> Subject: Re: custom runloop notification- which approach to take?
>
>
> If you grep the source you will see that CFMessagePorts currently use
> CFMachPorts:
>
> struct __CFMessagePort {
> CFRuntimeBase _base;
> CFSpinLock_t _lock;
> CFStringRef _name;
>
CFMachPortRef
_port; /*
immutable; invalidated */
> CFMutableDictionaryRef _replies;
> int32_t _convCounter;
> CFMachPortRef _replyPort; /* only used by remote
> port; immutable
> once created; invalidated */
>
CFRunLoopSourceRef
_source;
/* only used by
> local port; immutable
> once created; invalidated */
> CFMessagePortInvalidationCallBack _icallout;
> CFMessagePortCallBack _callout; /* only used by local
> port; immutable */
> CFMessagePortContext _context; /* not part of remote port;
> immutable; invalidated */
> };
>
> struct __CFMachPort {
> CFRuntimeBase _base;
> CFSpinLock_t _lock;
>
mach_port_t
_port; /*
immutable;
> invalidated */
>
mach_port_t
_oldnotify;
/* immutable; invalidated */
>
CFRunLoopSourceRef
_source;
/* immutable,
> once created; invalidated */
> CFMachPortInvalidationCallBack _icallout;
> CFMachPortCallBack _callout; /* immutable */
>
CFMachPortContext
_context;
/* immutable;
> invalidated */
> };
>
> If you need the source, I suggest visiting
> http://developer.apple.com/darwin/ (grepped the "CF" project) :-)
>
> There also notification centers (CFNotificationCenter in Carbon and
> NSNotificationCenter in Cocoa, IIRC) that you can use.
>
> Depending on your device, you may get some state changes for free (I'm
> thinking about USB plug/unplug events as an example). Just make sure
> you are not re-inventing the wheel...
>
> hth,
> Cheers,
> H.
>
> On 11/18/05, Philip Lukidis <
email@hidden> wrote:
> > Hopefully this is not OT. If so, my apologies (which list would be
> > appropriate then?).
> >
> > I have to implement a shared library (within a framework).
> The bottom edge
> > of the shared library will communicate with a daemon via
> local sockets
> > (the CFLocalServer was a helpful starter). However, I will
> > be required to notify the client of the shared library of
> interesting events
> > (changes in hardware, departure of hardware, etc). Within
> Windows, I might
> > have used custom messages to be send to a window procedure.
> However, I'm
> > not sure at all what would be the best way to proceed here with OSX.
> >
> > The simplest thing would be for the client of the shared
> library to send a
> > callback function, which I could invoke. But that's a bit
> bare bones, and
> > so I'm also looking into adding a custom source to a
> runloop, which would
> > result in a callback function being invoked. I'm just not
> sure which way
> > would be best for my needs. It seems that CFMessagePort
> would serve, but
> > there is also CFMachPort, and I don't know which is
> preferable. Concerning
> > CFMachPort, there is no CF interface for sending data to a port- the
> > CFMachPort doc says "To send data, you must use the Mach
> APIs with the
> > native Mach port, which is not described here." So where
> can I find this
> > documentation? I might cringe a bit if I should be forced
> to use native
> > mach APIs, because I'm not sure they would remain unchanged
> across OS
> > upgrades (perhaps this is an unreasonable fear, but I'm
> fairly new to OSX).
> >
> > Any thoughts? Are mach ports the way to go for this
> functionality, and, if
> > so, where might I find some mach API documentation for
> sending to a port?
> > If mach ports are not the way to go, what would be?
> (CFMessagePort for
> > example). I would like to stick to CF types, as I don't
> know right now what
> > type of application will be using the shared library (I
> understand that CF
> > types can be used by Carbon and Cocoa).
> >
> > thanks for any insight,
> >
> > Philip Lukidis
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Darwin-userlevel mailing list
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-userlevel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.