gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. bfeccc873ec7b9275819


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. bfeccc873ec7b927581953ef70127abb45d309b5
Date: Thu, 02 Dec 2010 15:30:59 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  bfeccc873ec7b927581953ef70127abb45d309b5 (commit)
      from  e1fd4745b89f6d6440016fad085551eb807b5754 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=bfeccc873ec7b927581953ef70127abb45d309b5


commit bfeccc873ec7b927581953ef70127abb45d309b5
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Dec 2 16:30:56 2010 +0100

    Use ptr_containers.

diff --git a/libcore/MovieLoader.cpp b/libcore/MovieLoader.cpp
index cb02d6d..a2a3418 100644
--- a/libcore/MovieLoader.cpp
+++ b/libcore/MovieLoader.cpp
@@ -17,10 +17,15 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
+#include "MovieLoader.h"
+
+#include <memory> 
+#include <boost/bind.hpp>
+#include <algorithm>
+
 #include "log.h"
 #include "MovieFactory.h"
 #include "movie_root.h"
-#include "MovieFactory.h"
 #include "DisplayObject.h"
 #include "as_value.h"
 #include "as_object.h"
@@ -33,9 +38,6 @@
 #include "RunResources.h"
 #include "StreamProvider.h"
 
-#include <memory> // for auto_ptr
-#include <boost/bind.hpp>
-
 //#define GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING 1
 //#define GNASH_DEBUG_LOCKING 1
 
@@ -65,8 +67,7 @@ MovieLoader::processRequests()
     while (1) {
 
         // check for shutdown/cancel request
-        if ( killed() )
-        {
+        if (killed()) {
 #ifdef GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING
             log_debug("Loader thread killed");
 #endif
@@ -88,8 +89,8 @@ MovieLoader::processRequests()
         Requests::iterator it = find_if(_requests.begin(), endIt,
                                         boost::bind(&Request::pending, _1));
 
-        if (it == endIt)
-        {
+        if (it == endIt) {
+
 #ifdef GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING
             log_debug("Movie loader thread getting to sleep (nothing more to 
do)");
 #endif
@@ -107,7 +108,7 @@ MovieLoader::processRequests()
             continue;
         }
 
-        Request* lr = *it;
+        Request& lr = *it;
 
 #ifdef GNASH_DEBUG_LOCKING
         log_debug("processRequests: lock on requests: release");
@@ -115,7 +116,7 @@ MovieLoader::processRequests()
 
         lock.unlock(); // now main thread can continue to push requests
 
-        processRequest(*lr);
+        processRequest(lr);
 
     }
 
@@ -152,8 +153,7 @@ MovieLoader::processRequest(Request& r)
 void
 MovieLoader::clear()
 {
-    if ( _thread.get() )
-    {
+    if (_thread.get()) {
 
 #ifdef GNASH_DEBUG_LOCKING
         log_debug("clear: lock on requests: trying");
@@ -175,7 +175,7 @@ MovieLoader::clear()
         log_debug("clear: lock on kill: obtained");
 #endif
 
-        _killed=true;
+        _killed = true;
 
 #ifdef GNASH_DEBUG_LOCKING
         log_debug("clear: lock on kill: release for kill");
@@ -183,7 +183,7 @@ MovieLoader::clear()
 
         lock.unlock();
 
-log_debug("waking up loader thread");
+        log_debug("waking up loader thread");
 
         _wakeup.notify_all(); // in case it was sleeping
 
@@ -192,9 +192,9 @@ log_debug("waking up loader thread");
 #endif
         requestsLock.unlock(); // allow the thread to die
 
-log_debug("MovieLoader notified, joining");
+        log_debug("MovieLoader notified, joining");
         _thread->join();
-log_debug("MovieLoader joined");
+        log_debug("MovieLoader joined");
         _thread.reset();
     }
 
@@ -211,11 +211,6 @@ log_debug("MovieLoader joined");
 void
 MovieLoader::clearRequests()
 {
-    for (Requests::iterator it=_requests.begin(),
-            end = _requests.end(); it != end; ++it)
-    {
-        delete *it;
-    }
     _requests.clear();
 }
 
@@ -343,46 +338,43 @@ MovieLoader::processCompletedRequests()
 {
     //GNASH_REPORT_FUNCTION;
 
-    for (;;)
-    {
+    for (;;) {
 
 #ifdef GNASH_DEBUG_LOCKING
-log_debug("processCompletedRequests: lock on requests: trying");
+        log_debug("processCompletedRequests: lock on requests: trying");
 #endif
 
-    boost::mutex::scoped_lock requestsLock(_requestsMutex);
+        boost::mutex::scoped_lock requestsLock(_requestsMutex);
 
 #ifdef GNASH_DEBUG_LOCKING
-log_debug("processCompletedRequests: lock on requests: obtained");
+        log_debug("processCompletedRequests: lock on requests: obtained");
 #endif
 
 #ifdef GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING
-    log_debug("Checking %d requests for completeness",
-        _requests.size());
+        log_debug("Checking %d requests for completeness",
+            _requests.size());
 #endif
 
+        Requests::iterator endIt = _requests.end();
+        Requests::iterator it = find_if(_requests.begin(), endIt,
+                                        boost::bind(&Request::completed, _1));
 
-    Request* firstCompleted = 0;
-    Requests::iterator endIt = _requests.end();
-    Requests::iterator it = find_if(_requests.begin(), endIt,
-                                    boost::bind(&Request::completed, _1));
-    if ( it != endIt ) firstCompleted=*it;
+        // Releases scoped lock.
+        if (it == endIt) break;
 
 #ifdef GNASH_DEBUG_LOCKING
-    log_debug("processCompletedRequests: lock on requests: releasing");
+        log_debug("processCompletedRequests: lock on requests: releasing");
 #endif
+        requestsLock.unlock();
 
-    requestsLock.unlock();
-
-    if ( firstCompleted )
-    {
+        Request& firstCompleted = *it;
 
 #ifdef GNASH_DEBUG_LOADMOVIE_REQUESTS_PROCESSING
         log_debug("Load request for target %s completed",
             firstCompleted->getTarget());
 #endif
 
-        bool checkit = processCompletedRequest(*firstCompleted);
+        bool checkit = processCompletedRequest(firstCompleted);
         assert(checkit);
 
 #ifdef GNASH_DEBUG_LOCKING
@@ -397,20 +389,13 @@ log_debug("processCompletedRequests: lock on requests: 
obtained");
                   "obtained");
 #endif
 
-        _requests.remove(firstCompleted);
-        delete firstCompleted;
+        _requests.erase(it);
 
 #ifdef GNASH_DEBUG_LOCKING
         log_debug("processCompletedRequests: lock on requests for removal: "
                   "release");
 #endif
     }
-    else
-    {
-        break;
-    }
-
-    }
 }
 
 // private
@@ -466,15 +451,13 @@ log_debug("loadMovie: lock on requests: obtained");
     );
 
     // Start or wake up the loader thread 
-    if ( ! _thread.get() )
-    {
+    if (!_thread.get()) {
         _killed=false;
         _thread.reset(new boost::thread(boost::bind(
                         &MovieLoader::processRequests, this)));
            _barrier.wait(); // let execution start before proceeding
     }
-    else
-    {
+    else {
         log_debug("loadMovie: waking up existing thread");
         _wakeup.notify_all();
     }
@@ -507,11 +490,8 @@ MovieLoader::setReachable() const
     log_debug("setReachable: lock on requests: obtained");
 #endif
 
-    for (Requests::const_iterator it=_requests.begin(),
-            end = _requests.end(); it != end; ++it)
-    {
-        (*it)->setReachable();
-    }
+    std::for_each(_requests.begin(), _requests.end(),
+            boost::mem_fn(&Request::setReachable));
 
 #ifdef GNASH_DEBUG_LOCKING
     log_debug("setReachable: lock on requests: release");
diff --git a/libcore/MovieLoader.h b/libcore/MovieLoader.h
index b539a27..3658568 100644
--- a/libcore/MovieLoader.h
+++ b/libcore/MovieLoader.h
@@ -19,18 +19,19 @@
 #ifndef GNASH_MOVIE_LOADER_H
 #define GNASH_MOVIE_LOADER_H
 
-#include "URL.h"
-#include "as_object.h" 
-#include "MovieClip.h" 
-
 #include <boost/intrusive_ptr.hpp>
 #include <list>
 #include <string>
+#include <boost/ptr_container/ptr_list.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/thread/thread.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread/barrier.hpp>
 
+#include "URL.h"
+#include "as_object.h" 
+#include "MovieClip.h" 
+
 // Forward declarations
 namespace gnash {
     class movie_root;
@@ -102,8 +103,7 @@ private:
                 _handler(handler),
                 _completed(false)
         {
-            if ( postdata )
-            {
+            if (postdata) {
                 _postData = *postdata;
                 _usePost = true;
             }
@@ -178,7 +178,7 @@ private:
     };
 
     /// Load requests
-    typedef std::list<Request*> Requests;
+    typedef boost::ptr_list<Request> Requests;
     Requests _requests;
 
        mutable boost::mutex _requestsMutex;

-----------------------------------------------------------------------

Summary of changes:
 libcore/MovieLoader.cpp |   92 ++++++++++++++++++----------------------------
 libcore/MovieLoader.h   |   14 ++++----
 2 files changed, 43 insertions(+), 63 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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