当前位置: 首页>>代码示例>>C++>>正文


C++ cache_type::end方法代码示例

本文整理汇总了C++中cache_type::end方法的典型用法代码示例。如果您正苦于以下问题:C++ cache_type::end方法的具体用法?C++ cache_type::end怎么用?C++ cache_type::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache_type的用法示例。


在下文中一共展示了cache_type::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: remove_lru

 /// Removes the least recently used element from the cache
 void remove_lru() const{
   cachelock.lock();
   KeyType keytoerase = lruage.back().key;
   // is the key I am invalidating in the cache?
   typename cache_type::iterator i = cache.find(keytoerase);
   if (i != cache.end()) {
     // drop it from the lru list
     delete i->second;
     cache.erase(i);
   }
   cachelock.unlock();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:13,代码来源:lazy_dht.hpp

示例2: cusparse_handle

inline cusparseHandle_t cusparse_handle(const command_queue &q) {
    typedef std::shared_ptr<std::remove_pointer<cusparseHandle_t>::type> smart_handle;
    typedef vex::detail::object_cache<vex::detail::index_by_context, smart_handle> cache_type;

    static cache_type cache;

    auto h = cache.find(q);

    if (h == cache.end()) {
        select_context(q);
        cusparseHandle_t handle;
        cuda_check( cusparseCreate(&handle) );
        cuda_check( cusparseSetStream(handle, q.raw()) );

        h = cache.insert(q, smart_handle(handle, detail::deleter()));
    }

    return h->second.get();
}
开发者ID:mariomulansky,项目名称:vexcl,代码行数:19,代码来源:cusparse.hpp

示例3: update_cache

 /// Updates the cache with this new value
 void update_cache(const KeyType &key, const ValueType &val) const{
   cachelock.lock();
   typename cache_type::iterator i = cache.find(key);
   // create a new entry
   if (i == cache.end()) {
     cachelock.unlock();
     // if we are out of room, remove the lru entry
     if (cache.size() >= maxcache) remove_lru();
     cachelock.lock();
     // insert the element, remember the iterator so we can push it
     // straight to the LRU list
     std::pair<typename cache_type::iterator, bool> ret = cache.insert(std::make_pair(key, new lru_entry_type(key, val)));
     if (ret.second)  lruage.push_front(*(ret.first->second));
   }
   else {
     // modify entry in place
     i->second->value = val;
     // swap to front of list
     //boost::swap_nodes(lru_list_type::s_iterator_to(i->second), lruage.begin());
     lruage.erase(lru_list_type::s_iterator_to(*(i->second)));
     lruage.push_front(*(i->second));
   }
   cachelock.unlock();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:25,代码来源:lazy_dht.hpp


注:本文中的cache_type::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。