client/commandQueue.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "commandQueue.h"
00019
00020 #ifdef GLX
00021 # include "glXMessagePump.h"
00022 #endif
00023 #ifdef WGL
00024 # include "wglMessagePump.h"
00025 #endif
00026 #ifdef AGL
00027 # include "aglMessagePump.h"
00028 #endif
00029
00030 using namespace std;
00031
00032 namespace eq
00033 {
00034 CommandQueue::CommandQueue()
00035 : _messagePump( 0 )
00036 , _windowSystem( WINDOW_SYSTEM_NONE )
00037 {
00038 }
00039
00040 CommandQueue::~CommandQueue()
00041 {
00042 delete _messagePump;
00043 _messagePump = 0;
00044 }
00045
00046 void CommandQueue::setWindowSystem( const WindowSystem windowSystem )
00047 {
00048 if( _windowSystem == windowSystem )
00049 return;
00050
00051 EQASSERTINFO( _windowSystem == WINDOW_SYSTEM_NONE,
00052 "Can't switch window system from " << _windowSystem << " to "
00053 << windowSystem );
00054 EQASSERT( !_windowSystem );
00055
00056 _windowSystem = windowSystem;
00057
00058 switch( windowSystem )
00059 {
00060 #ifdef GLX
00061 case WINDOW_SYSTEM_GLX:
00062 _messagePump = new GLXMessagePump();
00063 break;
00064 #endif
00065
00066 #ifdef WGL
00067 case WINDOW_SYSTEM_WGL:
00068 _messagePump = new WGLMessagePump();
00069 break;
00070 #endif
00071
00072 #ifdef AGL
00073 case WINDOW_SYSTEM_AGL:
00074 _messagePump = new AGLMessagePump();
00075 break;
00076 #endif
00077
00078 default:
00079 EQUNREACHABLE;
00080 }
00081 }
00082
00083 void CommandQueue::push(net::Command& inCommand)
00084 {
00085 net::CommandQueue::push(inCommand);
00086 if( _messagePump )
00087 _messagePump->postWakeup();
00088 }
00089
00090 void CommandQueue::pushFront(net::Command& inCommand)
00091 {
00092 net::CommandQueue::pushFront(inCommand);
00093 if( _messagePump )
00094 _messagePump->postWakeup();
00095 }
00096
00097 void CommandQueue::wakeup()
00098 {
00099 net::CommandQueue::wakeup();
00100 if( _messagePump )
00101 _messagePump->postWakeup();
00102 }
00103
00104 net::Command* CommandQueue::pop()
00105 {
00106 while( true )
00107 {
00108 if( _messagePump )
00109 _messagePump->dispatchAll();
00110
00111
00112 if( !isEmpty( ))
00113 return net::CommandQueue::pop();
00114
00115 if( _messagePump )
00116 _messagePump->dispatchOne();
00117 else
00118 return net::CommandQueue::pop();
00119 }
00120 }
00121
00122 net::Command* CommandQueue::tryPop()
00123 {
00124 if( _messagePump )
00125 _messagePump->dispatchAll();
00126
00127 return net::CommandQueue::tryPop();
00128 }
00129
00130 void CommandQueue::flush()
00131 {
00132 if( _messagePump )
00133 _messagePump->dispatchDone();
00134
00135 net::CommandQueue::flush();
00136 }
00137
00138 }