wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src network.cpp thread.cpp thread.hpp


From: Jon Daniel
Subject: [Wesnoth-cvs-commits] wesnoth/src network.cpp thread.cpp thread.hpp
Date: Mon, 08 Aug 2005 08:48:51 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Jon Daniel <address@hidden>     05/08/08 12:48:51

Modified files:
        src            : network.cpp thread.cpp thread.hpp 

Log message:
        Added error checking to the condition signals

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/network.cpp.diff?tr1=1.70&tr2=1.71&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/thread.cpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/thread.hpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: wesnoth/src/network.cpp
diff -u wesnoth/src/network.cpp:1.70 wesnoth/src/network.cpp:1.71
--- wesnoth/src/network.cpp:1.70        Fri Aug  5 23:01:13 2005
+++ wesnoth/src/network.cpp     Mon Aug  8 12:48:51 2005
@@ -1,4 +1,4 @@
-/* $Id: network.cpp,v 1.70 2005/08/05 23:01:13 j_daniel Exp $ */
+/* $Id: network.cpp,v 1.71 2005/08/08 12:48:51 j_daniel Exp $ */
 /*
    Copyright (C) 2003-5 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -333,7 +333,7 @@
        wassert(schemas.count(connect_) == 0);
        
schemas.insert(std::pair<network::connection,schema_pair>(connect_,schema_pair()));
 
-       notify_finished();
+       while(!notify_finished());
 }
 
 }
Index: wesnoth/src/thread.cpp
diff -u wesnoth/src/thread.cpp:1.9 wesnoth/src/thread.cpp:1.10
--- wesnoth/src/thread.cpp:1.9  Wed Jul 20 08:22:37 2005
+++ wesnoth/src/thread.cpp      Mon Aug  8 12:48:51 2005
@@ -1,4 +1,4 @@
-/* $Id: thread.cpp,v 1.9 2005/07/20 08:22:37 ott Exp $ */
+/* $Id: thread.cpp,v 1.10 2005/08/08 12:48:51 j_daniel Exp $ */
 /*
    Copyright (C) 2003-5 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -12,13 +12,14 @@
 */
 
 #include "global.hpp"
-
+#include "log.hpp"
 #include "thread.hpp"
 
 #include <new>
 #include <iostream>
 #include <vector>
 
+#define ERR_G LOG_STREAM(err, general)
 namespace {
 
 int run_async_operation(void* data)
@@ -128,19 +129,27 @@
        }
 }
 
-void condition::notify_one()
+bool condition::notify_one()
 {
-       SDL_CondSignal(cond_);
+       if(SDL_CondSignal(cond_) < 0) {
+               ERR_G << "SDL_CondSignal: " << SDL_GetError() << "\n";
+               return false;
+       }
+       return true;
 }
 
-void condition::notify_all()
+bool condition::notify_all()
 {
-       SDL_CondBroadcast(cond_);
+       if(SDL_CondBroadcast(cond_) < 0) {
+               ERR_G << "SDL_CondBroadcast: " << SDL_GetError() << "\n";
+               return false;
+       }
+       return true;
 }
 
-void async_operation::notify_finished()
+bool async_operation::notify_finished()
 {
-       finished_.notify_one();
+       return finished_.notify_one();
 }
 
 async_operation::RESULT async_operation::execute(waiter& wait)
Index: wesnoth/src/thread.hpp
diff -u wesnoth/src/thread.hpp:1.6 wesnoth/src/thread.hpp:1.7
--- wesnoth/src/thread.hpp:1.6  Wed Jul 20 08:22:37 2005
+++ wesnoth/src/thread.hpp      Mon Aug  8 12:48:51 2005
@@ -1,4 +1,4 @@
-/* $Id: thread.hpp,v 1.6 2005/07/20 08:22:37 ott Exp $ */
+/* $Id: thread.hpp,v 1.7 2005/08/08 12:48:51 j_daniel Exp $ */
 /*
    Copyright (C) 2003-5 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -161,18 +161,14 @@
        // signal the condition and wake up one thread waiting on the
        // condition. If no thread is waiting, notify_one() is a no-op.
        // Does not unlock the mutex.
-       //
-       // \todo SDL_CondSignal can return an error. This is never checked
-       void notify_one();
+       bool notify_one();
 
        // signal all threads waiting on the condition and let them contend
        // for the lock. This is often used when varying resource amounts are
        // involved and you do not know how many processes might continue.
        // The function should be used with care, especially if many threads are
        // waiting on the condition variable.
-       //
-       // \todo SDL_CondBroadcast can return an error. This is never checked
-       void notify_all();
+       bool notify_all();
 
 private:
        condition(const condition&);
@@ -218,7 +214,7 @@
        //while holding the mutex and after checking is_aborted()
        //if we want to be sure that if the operation is completed, the caller 
is notified.
        //will be called in any case after the operation returns
-       void notify_finished();
+       bool notify_finished();
 
        //must hold the mutex before calling this function from the worker 
thread
        bool is_aborted() const { return aborted_; }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]