Changeset 8:dba41f33ddce in xplcommon for test/testevent.cc
- Timestamp:
- 12/29/12 08:01:50 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/testevent.cc
r4 r8 89 89 //------------------------------------------------------------------------------ 90 90 91 class BlockingServerThread : public Thread 92 { 93 private: 94 WaitableEvent event; 95 96 public: 97 WaitableEvent& getEvent(); 98 99 virtual void run(); 100 }; 101 102 //------------------------------------------------------------------------------ 103 104 inline WaitableEvent& BlockingServerThread::getEvent() 105 { 106 return event; 107 } 108 109 //------------------------------------------------------------------------------ 110 111 void BlockingServerThread::run() 112 { 113 printf("BlockingServerThread::run: waiting...\n"); 114 if (event.check()) { 115 printf("BlockingServerThread::run: waiting done\n"); 116 } else { 117 printf("BlockingServerThread::run: waiting failed\n"); 118 } 119 printf("BlockingServerThread::run: finished\n"); 120 } 121 122 123 //------------------------------------------------------------------------------ 124 //------------------------------------------------------------------------------ 125 91 126 class ClientThread : public Thread 92 127 { … … 120 155 //------------------------------------------------------------------------------ 121 156 122 int main()157 template <class Server> void runTest() 123 158 { 124 Server ThreadserverThread;159 Server serverThread; 125 160 ClientThread clientThread(serverThread.getEvent()); 126 161 … … 134 169 serverThread.join(); 135 170 printf("Both threads returned\n"); 171 } 172 173 //------------------------------------------------------------------------------ 174 //------------------------------------------------------------------------------ 175 176 int main() 177 { 178 printf("Running the event test with a non-blocking WaitableEvent\n\n"); 179 runTest<ServerThread>(); 180 181 printf("\n\nRunning the event test with a blocking WaitableEvent\n\n"); 182 runTest<BlockingServerThread>(); 136 183 137 184 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.