From 299640ce5f6499e07c5799f48897ac5a77e72c54 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 18 Jul 2012 01:26:34 -0600 Subject: Persistant multi-threading works perfectly. It uses the forever-blocking variation of the Bu::SynchroQueue dequeue to maximize efficiency. --- src/explicitsimulation.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/explicitsimulation.h') diff --git a/src/explicitsimulation.h b/src/explicitsimulation.h index c2aeed9..7713c71 100644 --- a/src/explicitsimulation.h +++ b/src/explicitsimulation.h @@ -31,6 +31,9 @@ namespace Genetic protected: void updateFitness(); void setFitness( Genetic::PhenotypeId, double dFitness ); + void workDone(); + void setRunning( bool b ); + bool isRunning(); protected: Population xPop; @@ -49,8 +52,12 @@ namespace Genetic PhenotypeId uMaxFitness; Bu::Mutex mFitness; + Bu::Condition cWorkDone; typedef Bu::SynchroQueue WorkQueue; WorkQueue qWork; + int iWorkDone; + bool bRunning; + Bu::Mutex mRunning; class Processor : public Bu::Thread { @@ -59,8 +66,6 @@ namespace Genetic WorkQueue &rqWork, int iId ); virtual ~Processor(); - void setRunning( bool b ) { bRunning = b; } - protected: virtual void run(); @@ -68,7 +73,6 @@ namespace Genetic FitnessFunction *pFunc; WorkQueue &rqWork; int iId; - bool bRunning; }; typedef Bu::List ProcessorList; -- cgit v1.2.3