From 0e29a5da324e82afb457eab1755e52ea53d95aa0 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Wed, 17 Dec 2008 09:35:45 +0100 Subject: [PATCH] Make DiGMO problem use boost.thread instead of pthreads. --- main.cpp | 147 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 72 insertions(+), 75 deletions(-) diff --git a/main.cpp b/main.cpp index 969529d..fa77e2d 100644 --- a/main.cpp +++ b/main.cpp @@ -732,10 +732,8 @@ while (choice != -1) { //We instanciate the objects needed for pthreads allocating memory for the threads array pthread_t *threads; threads = new pthread_t [islandsN]; - pthread_mutex_t mutex; - pthread_cond_t exitcond; - pthread_mutex_init(&mutex, NULL); - pthread_cond_init (&exitcond, NULL); + boost::mutex mutex; + boost::condition_variable exitcond; //We allocate memory for the isActive array containing the status ofeach thread and we initialise it to false (no threads opened) bool *isActive; @@ -787,84 +785,83 @@ while (choice != -1) { int IslandType = 0; double loweststd = 1000000; - pthread_mutex_lock (&mutex); - time(&start); - while(iter < itermax){ - for (int i=0;i