home *** CD-ROM | disk | FTP | other *** search
- /****
- * CNeoBenchDoc.h
- *
- * Document class for a typical application.
- *
- ****/
- #pragma once /* Include this file only once */
-
- #include "NeoBench.h"
- #include "CFiller.h"
- #include CNeoPersistH
- #include <Timer.h>
-
- #include CNeoDocNativeH
-
- #ifndef qNeoPersist
- class CNeoIndexIterator;
- #endif
-
- #ifdef qNeoThreads
- #include CNeoThreadNativeH
-
- class CNeoBenchDoc;
-
- typedef enum {
- kDie,
- kAlive
- } health;
-
- #define kMaxThreads 5
-
- typedef struct {
- short phase; /* Phase of work being done */
- health state; /* Healthiness of this thread */
- CNeoBenchDoc * document; /* Document this thread is working for */
- CNeoThreadNative * thread; /* Pointer to thread */
- } ThreadInfo;
-
- class CBenchThread : public CNeoThreadNative
- {
- public:
- CBenchThread(ThreadInfo *aInfo, const NeoThreadType aType = kNeoCoopThread, void **aArg = nil, const Size aStackSize = 0, const NeoThreadOptions aOptions = (kUsePremadeThread + kCreateIfNeeded));
- virtual long run(void);
-
- virtual void handleSwapIn(void);
- virtual void handleSwapOut(void);
-
- protected:
- Boolean fSetTimer;
- TMTask fTimer;
- ThreadInfo * fInfo;
- };
- #endif
-
- typedef CNeoDocNative CNeoBenchDocBase;
-
- class CNeoBenchDoc : public CNeoBenchDocBase {
- public:
- // Construction/Destruction
- CNeoBenchDoc(const Boolean aPrintable, const Boolean aNewFile, const Boolean aRemote);
- virtual void buildWindow(void);
- virtual Boolean Close(Boolean aQuitting);
- virtual void DoCommand(long theCommand);
- virtual void NewFile(void);
- virtual void OpenFile(SFReply *macSFReply);
-
- // Filing
- virtual void Dawdle(long *maxSleep);
- void doSomeWork(const short aPhase, TMTask *aTimer);
- void getTargetTotals(void);
- #ifdef qNeoThreads
- void killThreads(void);
- #endif
- virtual void ProviderChanged(CCollaborator *aProvider, long reason, void* info);
- void setPhase(const short aPhase);
- Boolean getState(void);
- void setState(const Boolean aState);
-
- NeoPhase fPhaseInfo[kMaxPhase +1]; // The main phases
- Boolean fState; // Running state
- Boolean fRefresh; // Update stats on screen
- short fPhase; // The current phase
- #ifdef qNeoThreads
- short fThreadCount; // Current number of slave threads
- ThreadInfo fThreadInfo[kMaxThreads]; // Info used by each thread
- #endif
- #ifndef qNeoPersist
- CNeoIndexIterator * fIterator; // For traversing index of objects
- #endif
- CFiller * fObject; // Object pointer for serially finding objects
- long col_value[3]; // 3 columns - soFar, PerRecord, Total
- short col_index; // Index into the column
- };