gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11726: Tabs to spaces


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11726: Tabs to spaces
Date: Mon, 21 Dec 2009 20:04:17 +0100
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 11726
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Mon 2009-12-21 20:04:17 +0100
message:
  Tabs to spaces
modified:
  libbase/GC.cpp
  libbase/GC.h
=== modified file 'libbase/GC.cpp'
--- a/libbase/GC.cpp    2009-12-16 20:35:26 +0000
+++ b/libbase/GC.cpp    2009-12-21 19:04:17 +0000
@@ -38,163 +38,163 @@
 GC&
 GC::init(GcRoot& root)
 {
-       assert(!_singleton);
-       _singleton = new GC(root);
-       char *gcgap = std::getenv("GNASH_GC_TRIGGER_THRESHOLD");
-       if ( gcgap )
-       {
-               unsigned int gap = strtoul(gcgap, NULL, 0);
-               _singleton->maxNewCollectablesCount = gap;
-       }
-       return *_singleton;
+    assert(!_singleton);
+    _singleton = new GC(root);
+    char *gcgap = std::getenv("GNASH_GC_TRIGGER_THRESHOLD");
+    if ( gcgap )
+    {
+        unsigned int gap = strtoul(gcgap, NULL, 0);
+        _singleton->maxNewCollectablesCount = gap;
+    }
+    return *_singleton;
 }
 
 GC&
 GC::get()
 {
-       assert(_singleton);
-       return *_singleton;
+    assert(_singleton);
+    return *_singleton;
 }
 
 void
 GC::cleanup()
 {
-       assert(_singleton);
-       delete _singleton;
-       _singleton = NULL;
+    assert(_singleton);
+    delete _singleton;
+    _singleton = NULL;
 }
 
 GC::~GC()
 {
 #ifdef GNASH_GC_DEBUG 
-       log_debug(_("GC deleted, deleting all managed resources - collector run 
%d times"), _collectorRuns);
+    log_debug(_("GC deleted, deleting all managed resources - collector run %d 
times"), _collectorRuns);
 #endif
 
 #if 1
-       for (ResList::iterator i=_resList.begin(), e=_resList.end(); i!=e; ++i)
-       {
-               delete *i;
-       }
+    for (ResList::iterator i=_resList.begin(), e=_resList.end(); i!=e; ++i)
+    {
+        delete *i;
+    }
 #endif
 }
 
 size_t
 GC::cleanUnreachable()
 {
-       size_t deleted = 0;
+    size_t deleted = 0;
 
 #if (GNASH_GC_DEBUG > 1)
-       log_debug(_("GC: sweep scan started"));
+    log_debug(_("GC: sweep scan started"));
 #endif
 
-       for (ResList::iterator i=_resList.begin(), e=_resList.end(); i!=e; )
-       {
-               const GcResource* res = *i;
-               if ( ! res->isReachable() )
-               {
+    for (ResList::iterator i=_resList.begin(), e=_resList.end(); i!=e; )
+    {
+        const GcResource* res = *i;
+        if ( ! res->isReachable() )
+        {
 #if GNASH_GC_DEBUG > 1
-                       log_debug(_("GC: recycling object %p (%s)"), res, 
typeName(*res));
+            log_debug(_("GC: recycling object %p (%s)"), res, typeName(*res));
 #endif
-                       ++deleted;
-                       delete res;
-                       i = _resList.erase(i); // _resListSize updated at end 
of loop
-               }
-               else
-               {
-                       res->clearReachable();
-                       ++i;
-               }
-       }
+            ++deleted;
+            delete res;
+            i = _resList.erase(i); // _resListSize updated at end of loop
+        }
+        else
+        {
+            res->clearReachable();
+            ++i;
+        }
+    }
 
-       _resListSize -= deleted;
+    _resListSize -= deleted;
 
 #ifdef GNASH_GC_DEBUG 
-       log_debug(_("GC: recycled %d unreachable resources - %d left"),
-                       deleted, _resListSize);
+    log_debug(_("GC: recycled %d unreachable resources - %d left"),
+            deleted, _resListSize);
 #endif
 
 
-       return deleted;
+    return deleted;
 }
 
 void 
 GC::collect()
 {
-       // Heuristic to decide wheter or not to run the collection cycle
-       //
-       //
-       // Things to consider:
-       //
-       //  - Cost 
-       //      - Depends on the number of reachable collectables
-       //      - Depends on the frequency of runs
-       //
-       //  - Advantages 
-       //      - Depends on the number of unreachable collectables
-       //
-       //  - Cheaply computable informations
-       //      - Number of collectables (currently O(n) but can be optimized)
-       //      - Total heap-allocated memory (currently unavailable)
-       //
-       // Current heuristic:
-       //
-       //  - We run the cycle again if X new collectables were allocated
-       //    since last cycle run. X defaults to maxNewCollectablesCount
-       //    and can be changed by user (GNASH_GC_TRIGGER_THRESHOLD env
-       //    variable).
-       //
-       // Possible improvements:
-       //
-       //  - Adapt X (maxNewCollectablesCount) based on cost/advantage
-       //    runtime analisys
-       //
+    // Heuristic to decide wheter or not to run the collection cycle
+    //
+    //
+    // Things to consider:
+    //
+    //  - Cost 
+    //      - Depends on the number of reachable collectables
+    //      - Depends on the frequency of runs
+    //
+    //  - Advantages 
+    //      - Depends on the number of unreachable collectables
+    //
+    //  - Cheaply computable informations
+    //      - Number of collectables (currently O(n) but can be optimized)
+    //      - Total heap-allocated memory (currently unavailable)
+    //
+    // Current heuristic:
+    //
+    //  - We run the cycle again if X new collectables were allocated
+    //    since last cycle run. X defaults to maxNewCollectablesCount
+    //    and can be changed by user (GNASH_GC_TRIGGER_THRESHOLD env
+    //    variable).
+    //
+    // Possible improvements:
+    //
+    //  - Adapt X (maxNewCollectablesCount) based on cost/advantage
+    //    runtime analisys
+    //
 
-       if ( _resListSize <  _lastResCount + maxNewCollectablesCount )
-       {
+    if ( _resListSize <  _lastResCount + maxNewCollectablesCount )
+    {
 #if GNASH_GC_DEBUG  > 1
-               log_debug(_("GC: collection cycle skipped - %d/%d new resources 
allocated since last run (from %d to %d)"), _resListSize-_lastResCount, 
maxNewCollectablesCount, _lastResCount, _resListSize);
+        log_debug(_("GC: collection cycle skipped - %d/%d new resources 
allocated since last run (from %d to %d)"), _resListSize-_lastResCount, 
maxNewCollectablesCount, _lastResCount, _resListSize);
 #endif // GNASH_GC_DEBUG
-               return;
-       }
+        return;
+    }
 
-       //
-       // Collection cycle
-       //
+    //
+    // Collection cycle
+    //
 
 #ifdef GNASH_GC_DEBUG 
-       ++_collectorRuns;
+    ++_collectorRuns;
 #endif
 
 #ifdef GNASH_GC_DEBUG 
-       log_debug(_("GC: collection cycle started - %d/%d new resources 
allocated since last run (from %d to %d)"), _resListSize-_lastResCount, 
maxNewCollectablesCount, _lastResCount, _resListSize);
+    log_debug(_("GC: collection cycle started - %d/%d new resources allocated 
since last run (from %d to %d)"), _resListSize-_lastResCount, 
maxNewCollectablesCount, _lastResCount, _resListSize);
 #endif // GNASH_GC_DEBUG
 
 #ifndef NDEBUG
-       boost::thread self;
-       assert(self == mainThread);
+    boost::thread self;
+    assert(self == mainThread);
 #endif
 
-       // Mark all resources as reachable
-       markReachable();
-
-       // clean unreachable resources, and mark the others as reachable again
-       cleanUnreachable();
-
-       _lastResCount = _resListSize;
-
-       //assert(_lastResCount == _resList.size()); // O(n)...
+    // Mark all resources as reachable
+    markReachable();
+
+    // clean unreachable resources, and mark the others as reachable again
+    cleanUnreachable();
+
+    _lastResCount = _resListSize;
+
+    //assert(_lastResCount == _resList.size()); // O(n)...
 
 }
 
 void
 GC::countCollectables(CollectablesCount& count) const
 {
-       for (ResList::const_iterator i=_resList.begin(), e=_resList.end(); 
i!=e; ++i)
-       {
-               const GcResource* res = *i;
-               std::string type = typeName(*res);
-               count[type]++;
-       }
+    for (ResList::const_iterator i=_resList.begin(), e=_resList.end(); i!=e; 
++i)
+    {
+        const GcResource* res = *i;
+        std::string type = typeName(*res);
+        count[type]++;
+    }
 }
 
 } // end of namespace gnash

=== modified file 'libbase/GC.h'
--- a/libbase/GC.h      2009-12-16 19:46:46 +0000
+++ b/libbase/GC.h      2009-12-21 19:04:17 +0000
@@ -68,17 +68,17 @@
 
 public:
 
-       /// Scan all GC resources reachable by this instance.
-       //
-       /// This function is invoked on roots registered to
-       /// the collector.
-       ///
-       /// Use setReachable() on the resources stored in this
-       /// container.
-       ///
-       virtual void markReachableResources() const=0;
+    /// Scan all GC resources reachable by this instance.
+    //
+    /// This function is invoked on roots registered to
+    /// the collector.
+    ///
+    /// Use setReachable() on the resources stored in this
+    /// container.
+    ///
+    virtual void markReachableResources() const=0;
 
-       virtual ~GcRoot() {}
+    virtual ~GcRoot() {}
 };
 
 /// Collectable resource
@@ -90,85 +90,85 @@
 
 public:
 
-       friend class GC;
-
-       /// Create a Garbage-collected resource.
-       //
-       /// The resource will be automatically registered with
-       /// the garbage collector singleton.
-       ///
-       GcResource();
-
-       /// \brief
-       /// Mark this resource as being reachable, possibly triggering
-       /// further marking of all resources reachable by this object.
-       //
-       /// If the object wasn't reachable before, this call triggers
-       /// scan of all contained objects too...
-       ///
-       void setReachable() const
-       {
-
-               if ( _reachable )
-               {
+    friend class GC;
+
+    /// Create a Garbage-collected resource.
+    //
+    /// The resource will be automatically registered with
+    /// the garbage collector singleton.
+    ///
+    GcResource();
+
+    /// \brief
+    /// Mark this resource as being reachable, possibly triggering
+    /// further marking of all resources reachable by this object.
+    //
+    /// If the object wasn't reachable before, this call triggers
+    /// scan of all contained objects too...
+    ///
+    void setReachable() const
+    {
+
+        if ( _reachable )
+        {
 #if GNASH_GC_DEBUG > 2
-                       log_debug(_("Instance %p of class %s already reachable, 
setReachable doing nothing"),
-                                       (void*)this, typeName(*this));
+            log_debug(_("Instance %p of class %s already reachable, 
setReachable doing nothing"),
+                    (void*)this, typeName(*this));
 #endif
-                       return;
-               }
+            return;
+        }
 
 #if GNASH_GC_DEBUG  > 2
-               log_debug(_("Instance %p of class %s set to reachable, scanning 
reachable resources from it"),
-                               (void*)this, typeid(*this).name());
+        log_debug(_("Instance %p of class %s set to reachable, scanning 
reachable resources from it"),
+                (void*)this, typeid(*this).name());
 #endif
 
-               _reachable = true;
-               markReachableResources();
-       }
-
-       /// Return true if this object is marked as reachable
-       bool isReachable() const { return _reachable; }
-
-       /// Clear the reachable flag
-       void clearReachable() const { _reachable = false; }
+        _reachable = true;
+        markReachableResources();
+    }
+
+    /// Return true if this object is marked as reachable
+    bool isReachable() const { return _reachable; }
+
+    /// Clear the reachable flag
+    void clearReachable() const { _reachable = false; }
 
 protected:
 
-       /// Scan all GC resources reachable by this instance.
-       //
-       /// This function is invoked everytime this object
-       /// switches from unreachable to reachable, and is
-       /// used to recursively mark all contained resources
-       /// as reachable.
-       ///
-       /// See setReachable(), which is the function to invoke
-       /// against all reachable methods.
-       ///
-       /// Feel free to assert(_reachable) in your implementation.
-       ///
-       /// The default implementation doesn't mark anything.
-       ///
-       virtual void markReachableResources() const
-       {
-               assert(_reachable);
+    /// Scan all GC resources reachable by this instance.
+    //
+    /// This function is invoked everytime this object
+    /// switches from unreachable to reachable, and is
+    /// used to recursively mark all contained resources
+    /// as reachable.
+    ///
+    /// See setReachable(), which is the function to invoke
+    /// against all reachable methods.
+    ///
+    /// Feel free to assert(_reachable) in your implementation.
+    ///
+    /// The default implementation doesn't mark anything.
+    ///
+    virtual void markReachableResources() const
+    {
+        assert(_reachable);
 #if GNASH_GC_DEBUG > 1
-               log_debug(_("Class %s didn't override the 
markReachableResources() method"), typeid(*this).name());
+        log_debug(_("Class %s didn't override the markReachableResources() 
method"), typeid(*this).name());
 #endif
-       }
+    }
 
-       /// Delete this resource.
-       //
-       /// This is protected to allow subclassing, but ideally it
-       /// sould be private, so only the GC is allowed to delete us.
-       ///
-       virtual ~GcResource()
-       {
-       }
+    /// Delete this resource.
+    //
+    /// This is protected to allow subclassing, but ideally it
+    /// sould be private, so only the GC is allowed to delete us.
+    ///
+    virtual ~GcResource()
+    {
+    }
 
 private:
 
-       mutable bool _reachable;
+    mutable bool _reachable;
 
 };
 
@@ -191,148 +191,148 @@
 
 public:
 
-       /// Init the singleton instance using the given GcRoot
-       //
-       static GC& init(GcRoot& r);
-
-       /// Delete the singleton. You'll need to call init() again
-       /// after this call, if you want to use the singleton.
-       //
-       /// See init(GcRoot&)
-       ///
-       static void cleanup();
-
-       /// Get the singleton 
-       //
-       /// An assertion will fail if the GC has not been initialized yet.
-       /// See init(GcRoot&).
-       ///
-       static GC& get();
-
-       /// Add an heap object to the list of managed collectables
-       //
-       /// The given object is expected not to be already in the
-       /// list. Failing to do so would just decrease performances
-       /// but might not be a problem. Anyway, an assertion will fail
-       /// if adding an object twice.
-       ///
-       /// PRECONDITIONS:
-       ///     - the object isn't already in this GC list.
-       ///     - the object isn't marked as reachable.
-       ///     - the object isn't managed by another GC (UNCHECKED)
-       ///
-       /// @param item
-       ///     The item to be managed by this collector.
-       ///     Can't be NULL. The caller gives up ownerhip
-       ///     of it, which will only be deleted by this GC.
-       ///
-       void addCollectable(const GcResource* item)
-       {
+    /// Init the singleton instance using the given GcRoot
+    //
+    static GC& init(GcRoot& r);
+
+    /// Delete the singleton. You'll need to call init() again
+    /// after this call, if you want to use the singleton.
+    //
+    /// See init(GcRoot&)
+    ///
+    static void cleanup();
+
+    /// Get the singleton 
+    //
+    /// An assertion will fail if the GC has not been initialized yet.
+    /// See init(GcRoot&).
+    ///
+    static GC& get();
+
+    /// Add an heap object to the list of managed collectables
+    //
+    /// The given object is expected not to be already in the
+    /// list. Failing to do so would just decrease performances
+    /// but might not be a problem. Anyway, an assertion will fail
+    /// if adding an object twice.
+    ///
+    /// PRECONDITIONS:
+    /// - the object isn't already in this GC list.
+    /// - the object isn't marked as reachable.
+    /// - the object isn't managed by another GC (UNCHECKED)
+    ///
+    /// @param item
+    /// The item to be managed by this collector.
+    /// Can't be NULL. The caller gives up ownerhip
+    /// of it, which will only be deleted by this GC.
+    ///
+    void addCollectable(const GcResource* item)
+    {
 #ifndef NDEBUG
-               boost::thread self;
-               assert(self == mainThread);
-               assert(item);
-               assert(! item->isReachable());
-               // The following assertion is expensive ...
-               //assert(std::find(_resList.begin(), _resList.end(), item) == 
_resList.end());
+        boost::thread self;
+        assert(self == mainThread);
+        assert(item);
+        assert(! item->isReachable());
+        // The following assertion is expensive ...
+        //assert(std::find(_resList.begin(), _resList.end(), item) == 
_resList.end());
 #endif
 
-               _resList.push_back(item); ++_resListSize;
+        _resList.push_back(item); ++_resListSize;
 #if GNASH_GC_DEBUG > 1
-               log_debug(_("GC: collectable %p added, num collectables: %d"), 
item, _resListSize);
+        log_debug(_("GC: collectable %p added, num collectables: %d"), item, 
_resListSize);
 #endif
-       }
-
-
-       /// Run the collector
-       //
-       /// Find all reachable collectables, destroy all the others.
-       ///
-       void collect();
-
-       typedef std::map<std::string, unsigned int> CollectablesCount;
-
-       /// Count collectables
-       void countCollectables(CollectablesCount& count) const;
+    }
+
+
+    /// Run the collector
+    //
+    /// Find all reachable collectables, destroy all the others.
+    ///
+    void collect();
+
+    typedef std::map<std::string, unsigned int> CollectablesCount;
+
+    /// Count collectables
+    void countCollectables(CollectablesCount& count) const;
 
 private:
 
-       /// Number of newly registered collectable since last collection run
-       /// triggering next collection.
-       static unsigned int maxNewCollectablesCount;
-
-       /// Create a garbage collector, using the given root
-       GC(GcRoot& root)
-               :
-               _resListSize(0),
-               _root(root),
-               _lastResCount(0)
-#ifdef GNASH_GC_DEBUG 
-               , _collectorRuns(0)
-#endif
-       {
-#ifdef GNASH_GC_DEBUG 
-               log_debug(_("GC %p created"), (void*)this);
-#endif
-       }
-
-       /// Destroy the collector, releasing all collectables.
-       ~GC();
-
-       /// List of collectables
-       typedef std::list<const GcResource *> ResList;
-
-       /// Mark all reachable resources
-       void markReachable()
-       {
+    /// Number of newly registered collectable since last collection run
+    /// triggering next collection.
+    static unsigned int maxNewCollectablesCount;
+
+    /// Create a garbage collector, using the given root
+    GC(GcRoot& root)
+        :
+        _resListSize(0),
+        _root(root),
+        _lastResCount(0)
+#ifdef GNASH_GC_DEBUG 
+        , _collectorRuns(0)
+#endif
+    {
+#ifdef GNASH_GC_DEBUG 
+        log_debug(_("GC %p created"), (void*)this);
+#endif
+    }
+
+    /// Destroy the collector, releasing all collectables.
+    ~GC();
+
+    /// List of collectables
+    typedef std::list<const GcResource *> ResList;
+
+    /// Mark all reachable resources
+    void markReachable()
+    {
 #if GNASH_GC_DEBUG > 2
-               log_debug(_("GC %p: MARK SCAN"), (void*)this);
+        log_debug(_("GC %p: MARK SCAN"), (void*)this);
 #endif
-               _root.markReachableResources();
-       }
-
-       /// Delete all unreachable objects, and mark the others unreachable 
again
-       //
-       /// @return number of objects deleted
-       ///
-       size_t cleanUnreachable();
-
-       /// List of collectable resources
-       ResList _resList;
-
-       // Size of the list above, to avoid the
-       // cost of computing it  ..
-       // .. this is O(n) on GNU stdc++ lib !
-       //
-       ResList::size_type _resListSize;
-
-       GcRoot& _root;
-
-       static GC* _singleton;
+        _root.markReachableResources();
+    }
+
+    /// Delete all unreachable objects, and mark the others unreachable again
+    //
+    /// @return number of objects deleted
+    ///
+    size_t cleanUnreachable();
+
+    /// List of collectable resources
+    ResList _resList;
+
+    // Size of the list above, to avoid the
+    // cost of computing it  ..
+    // .. this is O(n) on GNU stdc++ lib !
+    //
+    ResList::size_type _resListSize;
+
+    GcRoot& _root;
+
+    static GC* _singleton;
 
 #ifndef NDEBUG
-       /// The thread that initialized the GC is 
-       /// the only one allowed to run the collector
-       /// and to register collectable objects
-       boost::thread mainThread;
+    /// The thread that initialized the GC is 
+    /// the only one allowed to run the collector
+    /// and to register collectable objects
+    boost::thread mainThread;
 #endif
 
-       /// Number of resources in collectable list at end of last
-       /// collect() call.
-       ResList::size_type _lastResCount;
+    /// Number of resources in collectable list at end of last
+    /// collect() call.
+    ResList::size_type _lastResCount;
 
 #ifdef GNASH_GC_DEBUG 
-       /// Number of times the collector runs (stats/profiling)
-       size_t _collectorRuns;
+    /// Number of times the collector runs (stats/profiling)
+    size_t _collectorRuns;
 #endif
 };
 
 
 inline GcResource::GcResource()
-       :
-       _reachable(false)
+    :
+    _reachable(false)
 {
-       GC::get().addCollectable(this);
+    GC::get().addCollectable(this);
 }
 
 } // namespace gnash


reply via email to

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