Go to the documentation of this file.
19 #ifndef GNASH_MOVIELIBRARY_H
20 #define GNASH_MOVIELIBRARY_H
25 #include <boost/intrusive_ptr.hpp>
43 boost::intrusive_ptr<movie_definition>
def;
60 void setLimit(LibraryContainer::size_type limit)
66 bool get(
const std::string& key,
67 boost::intrusive_ptr<movie_definition>* ret)
69 std::lock_guard<std::mutex> lock(_mapMutex);
70 LibraryContainer::iterator it = _map.find(key);
71 if (it == _map.end())
return false;
73 *ret = it->second.def;
74 it->second.hitCount++;
83 if (_limit) limitSize(_limit - 1);
90 std::lock_guard<std::mutex> lock(_mapMutex);
97 std::lock_guard<std::mutex> lock(_mapMutex);
103 static bool findWorstHitCount(
const LibraryContainer::value_type&
a,
104 const LibraryContainer::value_type&
b)
106 return (
a.second.hitCount <
b.second.hitCount);
112 void limitSize(LibraryContainer::size_type max) {
119 while (_map.size() > max) {
120 std::lock_guard<std::mutex> lock(_mapMutex);
121 _map.erase(std::min_element(_map.begin(), _map.end(),
122 &findWorstHitCount));
127 mutable std::mutex _mapMutex;
unsigned hitCount
Definition: MovieLibrary.h:44
void add(const std::string &key, movie_definition *mov)
Definition: MovieLibrary.h:78
Library of SWF movies indexed by URL strings.
Definition: MovieLibrary.h:38
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
Definition: MovieLibrary.h:42
boost::intrusive_ptr< movie_definition > def
Definition: MovieLibrary.h:43
int getMovieLibraryLimit() const
Definition: rc.h:95
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
std::map< std::string, LibraryItem > LibraryContainer
Definition: MovieLibrary.h:47
@ a
Definition: GnashKey.h:147
bool get(const std::string &key, boost::intrusive_ptr< movie_definition > *ret)
Definition: MovieLibrary.h:66
void setLimit(LibraryContainer::size_type limit)
Definition: MovieLibrary.h:60
static RcInitFile & getDefaultInstance()
Return the default instance of RC file.
Definition: rc.cpp:61
MovieLibrary()
Definition: MovieLibrary.h:49
void clear()
Definition: MovieLibrary.h:95
@ b
Definition: GnashKey.h:148