aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Expand)AuthorAge
...
| * * less clumsy ladder texture, based on railsNils Dagsson Moskopp2011-08-01
| * Changing CONTENT_LADDER to be an extended blockMark Holmquist2011-08-01
| * Fixing ladders againMark Holmquist2011-08-01
| * Fixed a few problems in the ladder update, and changed the speed to account f...Mark Holmquist2011-08-01
| * Ladders implemented!Mark Holmquist2011-08-01
| * Added ladders--they don't have any use yet, thoughMark Holmquist2011-08-01
| * Merge remote-tracking branch 'origin/upstream'Nils Dagsson Moskopp2011-07-31
| |\
| * | last fix was shit but this one works (tested)Constantin Wenger2011-07-31
| * | fixe for msvc broke linuxConstantin Wenger2011-07-30
| * | this fixes problem with msvc++ and should work on other systems and so on any...Constantin Wenger2011-07-30
| * | changed one forgotten en_US.UTF-8 to CConstantin Wenger2011-07-30
| * | fixed redefinitivon of gettext.h is included more than onceConstantin Wenger2011-07-30
| * | set some more text to gettext and updated po filesConstantin Wenger2011-07-30
| * | set locales to C because en_US not installed on some systems, only UTF-8 vers...Constantin Wenger2011-07-30
| * | fixed displaying "umlauts" (deutsch umlaute) and hopefully other non ASCII ch...Constantin Wenger2011-07-30
| * | Merge branch 'upstream/master'Nils Dagsson Moskopp2011-07-30
| |\ \
| * \ \ Merge remote-tracking branch 'origin/upstream'Nils Dagsson Moskopp2011-07-30
| |\ \ \
| * | | | Locale dir should be parallel to global data dirGiuseppe Bilotta2011-07-24
| * | | | Read config from gettext.hGiuseppe Bilotta2011-07-24
| * | | | Actually make USE_GETTEXT available in the sourceGiuseppe Bilotta2011-07-24
| * | | | Two more instances of unhardcoding the project nameGiuseppe Bilotta2011-07-24
| * | | | Sanitize GETTEXT usage macrosGiuseppe Bilotta2011-07-24
| * | | | Bring po update out of cmake againGiuseppe Bilotta2011-07-24
| * | | | Refactor gettext initGiuseppe Bilotta2011-07-24
| * | | | Do not package en translation, since we don't build itGiuseppe Bilotta2011-07-24
| * | | | Gettext domain should match the project nameGiuseppe Bilotta2011-07-24
| * | | | Place project name and gettext use in configGiuseppe Bilotta2011-07-24
| * | | | Merge pull request #34 from SpeedProg/masterNils Dagsson Moskopp2011-07-23
| |\ \ \ \
| | * | | | updated cmakerules to autodetect if gettext can be usedConstantin Wenger2011-07-23
| | * | | | Merge remote-tracking branch 'upstream/master'Constantin Wenger2011-07-22
| | |\ \ \ \
| | | * \ \ \ Merge branch 'upstream/master'Nils Dagsson Moskopp2011-07-22
| | | |\ \ \ \
| | * | | | | | fixed some problems with filenames of the translationsConstantin Wenger2011-07-22
| | |/ / / / /
| | * | | | | Declare USE_GETTEXT optionGiuseppe Bilotta2011-07-22
| | * | | | | fixed problem with displaying special charsConstantin Wenger2011-07-22
| | * | | | | updatepo cmake ruleGiuseppe Bilotta2011-07-22
| | * | | | | Static naming of po fileGiuseppe Bilotta2011-07-22
| | * | | | | Refactor mo creation/installationGiuseppe Bilotta2011-07-22
| | * | | | | Use project name for mo filesGiuseppe Bilotta2011-07-22
| | * | | | | Merge remote-tracking branch 'erlehmann/master'Giuseppe Bilotta2011-07-22
| | |\ \ \ \ \
| | | * | | | | Added french translation.Cyriaque Skrapits2011-07-21
| | | * | | | | * different collision box for fireflies so they now hover above the groundNils Dagsson Moskopp2011-07-21
| | * | | | | | changed some lines to fit the 80chars limitConstantin Wenger2011-07-22
| | * | | | | | Reorganize cmake gettext message output to ease debuggingGiuseppe Bilotta2011-07-21
| | * | | | | | Restore "Leave address blank" positionGiuseppe Bilotta2011-07-21
| | * | | | | | Find correct library for MSVC vs MingW in WinowsGiuseppe Bilotta2011-07-21
| | * | | | | | Only install locale files if using gettextGiuseppe Bilotta2011-07-21
| | * | | | | | Uppercase DEFINED or cmake 2.8.4 complainsGiuseppe Bilotta2011-07-21
| | * | | | | | Refactor and clean up gettext managementGiuseppe Bilotta2011-07-21
| | * | | | | | Make gettext optionalGiuseppe Bilotta2011-07-21
| | * | | | | | Tweak makefiles to add -delta suffix.Weedy2011-07-21
="hl opt">); T t = m_queue.front(); m_queue.pop_front(); return t; } else { throw ItemNotFoundException("MutexedQueue: queue is empty"); } } T pop_frontNoEx() { m_signal.wait(); MutexAutoLock lock(m_mutex); T t = m_queue.front(); m_queue.pop_front(); return t; } T pop_back(u32 wait_time_max_ms=0) { if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } else { throw ItemNotFoundException("MutexedQueue: queue is empty"); } } /* this version of pop_back returns a empty element of T on timeout. * Make sure default constructor of T creates a recognizable "empty" element */ T pop_backNoEx(u32 wait_time_max_ms) { if (m_signal.wait(wait_time_max_ms)) { MutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } else { return T(); } } T pop_backNoEx() { m_signal.wait(); MutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } protected: Mutex &getMutex() { return m_mutex; } std::deque<T> &getQueue() { return m_queue; } std::deque<T> m_queue; mutable Mutex m_mutex; Semaphore m_signal; }; template<typename K, typename V> class LRUCache { public: LRUCache(size_t limit, void (*cache_miss)(void *data, const K &key, V *dest), void *data) { m_limit = limit; m_cache_miss = cache_miss; m_cache_miss_data = data; } void setLimit(size_t limit) { m_limit = limit; invalidate(); } void invalidate() { m_map.clear(); m_queue.clear(); } const V *lookupCache(K key) { typename cache_type::iterator it = m_map.find(key); V *ret; if (it != m_map.end()) { // found! cache_entry_t &entry = it->second; ret = &entry.second; // update the usage information m_queue.erase(entry.first); m_queue.push_front(key); entry.first = m_queue.begin(); } else { // cache miss -- enter into cache cache_entry_t &entry = m_map[key]; ret = &entry.second; m_cache_miss(m_cache_miss_data, key, &entry.second); // delete old entries if (m_queue.size() == m_limit) { const K &id = m_queue.back(); m_map.erase(id); m_queue.pop_back(); } m_queue.push_front(key); entry.first = m_queue.begin(); } return ret; } private: void (*m_cache_miss)(void *data, const K &key, V *dest); void *m_cache_miss_data; size_t m_limit; typedef typename std::template pair<typename std::template list<K>::iterator, V> cache_entry_t; typedef std::template map<K, cache_entry_t> cache_type; cache_type m_map; // we can't use std::deque here, because its iterators get invalidated std::list<K> m_queue; }; #endif