2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // machrunloopserver - C++ shell for writing Mach 3 servers called by CFRunLoop.
22 // Note that this is a subclass of MachServer and tries to preserve its interface,
23 // so you can switch back-and-forth between them with a minimum of fuss.
24 // Timers are not currently implemented; they're not that hard to add if you need them.
26 #ifndef _H_MACHRUNLOOPSERVER
27 #define _H_MACHRUNLOOPSERVER
29 #include <Security/machserver.h>
30 #include <CoreFoundation/CFRunLoop.h>
31 #include <CoreFoundation/CFMachPort.h>
37 namespace MachPlusPlus
43 class MachRunLoopServer
: public MachServer
{
45 MachRunLoopServer(const char *name
);
46 MachRunLoopServer(const char *name
, const Bootstrap
&boot
);
47 virtual ~MachRunLoopServer();
49 void run(size_t maxSize
= 4096, mach_msg_options_t options
= 0);
51 static MachRunLoopServer
&active()
52 { return safer_cast
<MachRunLoopServer
&>(MachServer::active()); }
54 void notifyIfDead(Port port
) const;
56 void blockNewRequests(bool block
= true);
58 void alsoListenOn(Port port
);
59 void stopListenOn(Port port
);
62 void setup(const char *name
, size_t bufferSize
);
63 static void cfCallback(CFMachPortRef port
, void *msg
, CFIndex size
, void *info
);
64 static void cfInvalidateCallback(CFMachPortRef port
, void *info
);
65 void oneRequest(mach_msg_header_t
*request
);
69 CFRunLoopSourceRef runLoopSource
;
71 mach_msg_header_t
*replyBuffer
;
75 } // end namespace MachPlusPlus
77 } // end namespace Security
79 #endif //_H_MACHRUNLOOPSERVER