Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/db735101e9b0
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 01:21:05 2012
Кодировка:
allpy: db735101e9b0

allpy

changeset 845:db735101e9b0

blocks3d/wt: fix possible races in try_to_run() method of Blocks3DWidget Static object current_tasks is not thread-safe, but could be used by several wt's threads simultaneously. It was fixed by protecting the code with a boost::mutex.
author boris <bnagaev@gmail.com>
date Wed, 20 Jul 2011 03:05:06 +0200
parents 2ab571ea8101
children da46b25fd67d
files blocks3d/wt/blocks3d-wt-widget.C
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/blocks3d/wt/blocks3d-wt-widget.C	Wed Jul 20 02:46:23 2011 +0200
     1.2 +++ b/blocks3d/wt/blocks3d-wt-widget.C	Wed Jul 20 03:05:06 2011 +0200
     1.3 @@ -3,6 +3,7 @@
     1.4  #include <iostream>
     1.5  #include <boost/format.hpp>
     1.6  #include <boost/foreach.hpp>
     1.7 +#include <boost/thread/mutex.hpp>
     1.8  #include <cstdlib>
     1.9  #include <vector>
    1.10  #include <algorithm>
    1.11 @@ -21,6 +22,7 @@
    1.12  #include <Wt/WFileResource>
    1.13  
    1.14  std::vector<std::string> current_tasks;
    1.15 +boost::mutex current_tasks_mutex;
    1.16  
    1.17  Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget* parent) :
    1.18      Wt::WContainerWidget(parent),
    1.19 @@ -189,6 +191,7 @@
    1.20  
    1.21  void Blocks3DWidget::try_to_run()
    1.22  {
    1.23 +    boost::mutex::scoped_lock(current_tasks_mutex);
    1.24      std::remove_if(current_tasks.begin(), current_tasks.end(), &Blocks3DWidget::is_completed);
    1.25      if (current_tasks.size() >= Malakite::max_simultaneous_tasks)
    1.26      {