00001
00002 #ifndef D_SESSION_H
00003 #define D_SESSION_H
00004
00005
00006 #include "d_Transaction.h"
00007 #include "oNoTxContext.h"
00008
00009 #include "oThread.h"
00010
00011
00012 class oSession
00013 {
00014 public:
00015
00016 oSession( d_String iName );
00017 oSession( d_String iName, oThread::tEntry iEntryPoint, oThread::tArgument iArg, oUInt2 iFlag );
00018 ~oSession();
00019
00020 void addContext( const oContext* iTrans );
00021 void removeContext( const oContext* iTrans );
00022 oContext* getActiveContext() const;
00023 oNoTxContext* getNoTxContext() const;
00024
00025 bool wait();
00026
00027
00028 d_Object* getPendingObject() const;
00029
00030 void setPendingObject( d_Object* iPending );
00031
00032
00033 int getPendingEmbedded() const;
00034
00035 void setPendingEmbedded( int iPending );
00036
00037
00038 void forceShutdown( int iSignalCode );
00039
00040
00041 void checkForShutdown();
00042
00043 const char* getName() const;
00044 static otThreadFunc flow( oThread::tArgument iArg );
00045
00046 #ifdef OMT
00047 oThread::tId threadId() const;
00048 #endif
00049
00050 private:
00051
00052
00053
00054 d_String name;
00055
00056 oArray<oContext*> txs;
00057 oContext* activeContext;
00058
00059 d_Object* pendingObject;
00060 int pendingEmbedded;
00061
00062 oThread::tEntry entryPoint;
00063 oThread::tArgument argument;
00064
00065 bool shutdownCode;
00066 #ifdef OMT
00067 oThread* _thread;
00068 #endif
00069 };
00070
00071
00072 inline oContext* oSession::getActiveContext() const
00073 {
00074 return activeContext;
00075 }
00076
00077 inline oNoTxContext* oSession::getNoTxContext() const
00078 {
00079
00080 return static_cast<oNoTxContext*>( txs[0] );
00081 }
00082
00083 inline const char* oSession::getName() const
00084 {
00085 return name;
00086 }
00087
00088 #ifdef OMT
00089 inline oThread::tId oSession::threadId() const
00090 {
00091 if( _thread )
00092 return _thread->id();
00093
00094
00095 return 0;
00096 }
00097 #endif
00098
00099
00100
00101 #endif