home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Futures.h
-
- Contains: Header file for futures
-
- Written by: Andy Nicholas, Greg Anderson, Tom Conrad, Chris Bingham, Georgiann Puckett, John Thompson-Rohrlich, Max McFarland
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 7/21/94 andy include MixedMode.h to get kPascalStackBased
- <1> 7/6/94 ga first checked in
- 7/6/94 ga New today
-
- */
-
- #ifndef Futures_h
- #define Futures_h
-
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
- #ifndef __THREADS__
- #include <Threads.h>
- #endif
-
- //
- // Constants
- //
- #define kNoMaximumWait (0x7FFFFFFF)
-
- #if 0
-
- //
- // Keyword for refCon attribute not documented
- // in Inside Macintosh
- //
- #define keyRefconAttr 'refc'
-
- #endif
-
- //
- // Keyword keyAEResetTimerFrequency specifies
- // approximately how frequently (in ticks) the
- // client would like the server to call AEResetTimer.
- // This value is advisory only, and is typically
- // one-half of the timeout value.
- //
- #define keyAEResetTimerFrequencyAttr 'resf'
-
- //
- // This is how frequently a server should call
- // AEResetTimer if the AppleEvent message doesn't
- // contain a 'reset timer frequency' attribute
- //
- #define kDefaultResetTimerFrequency 30
-
- //
- // Values for InitFutures
- //
- #define kNoSpecialFutureFeatures 0
- #define kSpawnHousekeepingThread 0x0001
- #define kInstallAsyncPreDispatchHandler 0x0002
- #define kAllSpecialFutureFeatures (kSpawnHousekeepingThread | kInstallAsyncPreDispatchHandler)
-
- typedef pascal OSErr (*ThreadCreateProcPtr)(ThreadEntryProcPtr threadEntry, void* threadParam, long handlerRefCon, ThreadID* threadMade);
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- //
- // Prototypes for Future functions
- //
- OSErr InitFutures(ThreadCreateProcPtr threadCreateProc, long initFuturesFlags);
- void BlockUntilReal(AppleEvent* reply);
- Boolean ReplyArrived(AppleEvent* reply);
- void SetReplyTimeoutValue(AppleEvent* reply, long timeoutValue, long maxWaitTime);
- void IdleFutures();
- OSErr AskForFuture(const AppleEvent* ae, AppleEvent* reply, long timeoutValue, long maxWaitTime, AESendMode sendMode, AESendPriority sendPriority);
- long GetResetTimerFrequency(AppleEvent* ae);
- OSErr ResetTimerIfNecessary(AppleEvent* reply, unsigned long* lastReset, long resetFrequency);
-
- #ifdef __cplusplus
- }
-
- //
- // Default parameters: for use with C++ compilers
- //
- inline OSErr InitFutures(ThreadCreateProcPtr threadCreateProc = nil /* kAllSpecialFutureFeatures */) { return InitFutures(threadCreateProc, kAllSpecialFutureFeatures); }
- inline OSErr AskForFuture(const AppleEvent* ae, AppleEvent* reply, long timeoutValue = kAEDefaultTimeout, long maxWaitTime = kNoMaximumWait, AESendMode sendMode = 0 /* kAENormalPriority */) { return AskForFuture(ae, reply, timeoutValue, maxWaitTime, sendMode, kAENormalPriority); }
-
- #endif
-
- //
- // Backwards compatability API
- //
- #define IsFuture(reply) (!ReplyArrived(reply))
-
- #endif // Futures_h
-
-