F:/Dev-Cpp/Projects/Events System 1.0 Revision/main.cpp

Go to the documentation of this file.
00001 #include <cstdlib>
00002 #include <iostream>
00003 #include <string>
00004 #include <windows.h>
00005 #include <process.h>
00006 #include "Signals.hpp"
00007 
00008 using namespace std;
00009 using namespace EventsSystem::Signals;
00010 using namespace EventsSystem::Interfaces;
00011 
00012 
00013 HANDLE hRunMutex;                   // "Keep Running" mutex 
00014 HANDLE hScreenMutex;                // "Screen update" mutex
00015 int iThreadsCount;                  // Number of threads started
00016 
00017 void ShutDown() // Shut down threads 
00018 {
00019     while ( iThreadsCount > 0 )
00020     {
00021         // Tell thread to die and record its death.
00022         ReleaseMutex(hRunMutex);
00023         iThreadsCount--;   
00024     }
00025     
00026     // Clean up display when done
00027     WaitForSingleObject(hScreenMutex, INFINITE);
00028     
00029     CloseHandle(hScreenMutex);
00030     CloseHandle(hRunMutex);
00031 }
00032 
00033 int main()
00034 {
00035         // Create the mutexes and reset thread count.
00036   hScreenMutex = CreateMutex(NULL, FALSE, NULL);  // Cleared 
00037   hRunMutex = CreateMutex(NULL, TRUE, NULL);      // Set 
00038   iThreadsCount = 0;
00039         
00040         char c;
00041         
00042         //_beginthread(catchSignals, 0, &iThreadsCount);
00043         
00044         do
00045         {
00046                 fflush(stdin);
00047                 c = cin.get();
00048         }
00049         while ( c != 'q' );
00050 
00051         ShutDown();
00052         
00053   return EXIT_SUCCESS;
00054 }

Generated on Thu Apr 13 12:15:07 2006 for Events System by  doxygen 1.4.6-NO