|  |  | @@ -64,10 +64,10 @@ | 
		
	
		
			
			|  |  |  | #include <set> | 
		
	
		
			
			|  |  |  | #include <vector> | 
		
	
		
			
			|  |  |  | #include <string> | 
		
	
		
			
			|  |  |  | #include <queue> | 
		
	
		
			
			|  |  |  | #include "faults.hpp" | 
		
	
		
			
			|  |  |  | #include <queue> | 
		
	
		
			
			|  |  |  | #include "faults.hpp" | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | using namespace std; | 
		
	
		
			
			|  |  |  | namespace CodeDweller { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | class ThreadManager;                                                            // ThreadManager does exist. | 
		
	
		
			
			|  |  |  | extern ThreadManager Threads;                                                   // Master thread manager. | 
		
	
	
		
			
			|  |  | @@ -120,7 +120,7 @@ class ThreadStatusRecord { | 
		
	
		
			
			|  |  |  | Pointer(P), | 
		
	
		
			
			|  |  |  | Type(&T), | 
		
	
		
			
			|  |  |  | State(&S), | 
		
	
		
			
			|  |  |  | Name(N), | 
		
	
		
			
			|  |  |  | Name(N), | 
		
	
		
			
			|  |  |  | isRunning(R), | 
		
	
		
			
			|  |  |  | isBad(B), | 
		
	
		
			
			|  |  |  | Fault(F) | 
		
	
	
		
			
			|  |  | @@ -133,7 +133,7 @@ class ThreadStatusRecord { | 
		
	
		
			
			|  |  |  | isRunning = Right.isRunning; | 
		
	
		
			
			|  |  |  | isBad = Right.isBad; | 
		
	
		
			
			|  |  |  | Fault = Right.Fault; | 
		
	
		
			
			|  |  |  | Name = Right.Name; | 
		
	
		
			
			|  |  |  | Name = Right.Name; | 
		
	
		
			
			|  |  |  | return *this; | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
	
		
			
			|  |  | @@ -436,50 +436,50 @@ class ScopeThreadLock { | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // End Thread Manager | 
		
	
		
			
			|  |  |  | //////////////////////////////////////////////////////////////////////////////// | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | //////////////////////////////////////////////////////////////////////////////// | 
		
	
		
			
			|  |  |  | // A ProductionQueue is a templated, thread safe mechanism for implementing | 
		
	
		
			
			|  |  |  | // a producer/consumer relationship. The objects in the queue should be simple | 
		
	
		
			
			|  |  |  | // data so that they can be created, destroyed, and copied without trouble. Put | 
		
	
		
			
			|  |  |  | // another way - the objects in the ProductionQueue should be lightweight | 
		
	
		
			
			|  |  |  | // handles for other things. Those things should be created and destroyed | 
		
	
		
			
			|  |  |  | // elsewhere. | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | template<typename T>                                                            // Templatized | 
		
	
		
			
			|  |  |  | class ProductionQueue {                                                         // Production Queue Class | 
		
	
		
			
			|  |  |  | private: | 
		
	
		
			
			|  |  |  | Mutex myMutex;                                                              // Contains a mutex and | 
		
	
		
			
			|  |  |  | volatile unsigned int LatestSize;                                           // a volatile (blinking light) size | 
		
	
		
			
			|  |  |  | ProductionGateway myGateway;                                                // integrated with a production | 
		
	
		
			
			|  |  |  | queue<T> myQueue;                                                           // gateway and a queue. | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | public: | 
		
	
		
			
			|  |  |  | ProductionQueue() : LatestSize(0) {}                                        // The size always starts at zero. | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | T take() {                                                                  // To consume a queued object | 
		
	
		
			
			|  |  |  | myGateway.consume();                                                    // we wait on the production gateway | 
		
	
		
			
			|  |  |  | ScopeMutex OneAtATimePlease(myMutex);                                   // and when we get through we lock | 
		
	
		
			
			|  |  |  | T O = myQueue.front();                                                  // the mutext, take the object on the | 
		
	
		
			
			|  |  |  | myQueue.pop();                                                          // front of the queue, pop it out, | 
		
	
		
			
			|  |  |  | LatestSize = myQueue.size();                                            // and rest our size (blinking light). | 
		
	
		
			
			|  |  |  | return O;                                                               // Then return the object we got. | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | void give(T O) {                                                            // To produce a queued object | 
		
	
		
			
			|  |  |  | ScopeMutex OneAtATimePlease(myMutex);                                   // we wait on the mutex. When we | 
		
	
		
			
			|  |  |  | myQueue.push(O);                                                        // get through we push our object | 
		
	
		
			
			|  |  |  | LatestSize = myQueue.size();                                            // into the queue, reset our size | 
		
	
		
			
			|  |  |  | myGateway.produce();                                                    // indicator and tell the gateway. | 
		
	
		
			
			|  |  |  | }                                                                           // When we're done it can be grabbed. | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | unsigned int size() {                                                       // To check the size we look at | 
		
	
		
			
			|  |  |  | return LatestSize;                                                      // the blinking light. | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }; | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // End Production Queue | 
		
	
		
			
			|  |  |  | //////////////////////////////////////////////////////////////////////////////// | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | //////////////////////////////////////////////////////////////////////////////// | 
		
	
		
			
			|  |  |  | // A ProductionQueue is a templated, thread safe mechanism for implementing | 
		
	
		
			
			|  |  |  | // a producer/consumer relationship. The objects in the queue should be simple | 
		
	
		
			
			|  |  |  | // data so that they can be created, destroyed, and copied without trouble. Put | 
		
	
		
			
			|  |  |  | // another way - the objects in the ProductionQueue should be lightweight | 
		
	
		
			
			|  |  |  | // handles for other things. Those things should be created and destroyed | 
		
	
		
			
			|  |  |  | // elsewhere. | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | template<typename T>                                                            // Templatized | 
		
	
		
			
			|  |  |  | class ProductionQueue {                                                         // Production Queue Class | 
		
	
		
			
			|  |  |  | private: | 
		
	
		
			
			|  |  |  | Mutex myMutex;                                                              // Contains a mutex and | 
		
	
		
			
			|  |  |  | volatile unsigned int LatestSize;                                           // a volatile (blinking light) size | 
		
	
		
			
			|  |  |  | ProductionGateway myGateway;                                                // integrated with a production | 
		
	
		
			
			|  |  |  | queue<T> myQueue;                                                           // gateway and a queue. | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | public: | 
		
	
		
			
			|  |  |  | ProductionQueue() : LatestSize(0) {}                                        // The size always starts at zero. | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | T take() {                                                                  // To consume a queued object | 
		
	
		
			
			|  |  |  | myGateway.consume();                                                    // we wait on the production gateway | 
		
	
		
			
			|  |  |  | ScopeMutex OneAtATimePlease(myMutex);                                   // and when we get through we lock | 
		
	
		
			
			|  |  |  | T O = myQueue.front();                                                  // the mutext, take the object on the | 
		
	
		
			
			|  |  |  | myQueue.pop();                                                          // front of the queue, pop it out, | 
		
	
		
			
			|  |  |  | LatestSize = myQueue.size();                                            // and rest our size (blinking light). | 
		
	
		
			
			|  |  |  | return O;                                                               // Then return the object we got. | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | void give(T O) {                                                            // To produce a queued object | 
		
	
		
			
			|  |  |  | ScopeMutex OneAtATimePlease(myMutex);                                   // we wait on the mutex. When we | 
		
	
		
			
			|  |  |  | myQueue.push(O);                                                        // get through we push our object | 
		
	
		
			
			|  |  |  | LatestSize = myQueue.size();                                            // into the queue, reset our size | 
		
	
		
			
			|  |  |  | myGateway.produce();                                                    // indicator and tell the gateway. | 
		
	
		
			
			|  |  |  | }                                                                           // When we're done it can be grabbed. | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | unsigned int size() {                                                       // To check the size we look at | 
		
	
		
			
			|  |  |  | return LatestSize;                                                      // the blinking light. | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | }; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // End Production Queue | 
		
	
		
			
			|  |  |  | //////////////////////////////////////////////////////////////////////////////// | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | #endif | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // End Of Include MNR_threading Once Only ====================================== |