• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ policy_type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: operator

  KOKKOS_INLINE_FUNCTION
  void operator()( typename policy_type::member_type & )
    {
       enum { CHUNK = 8 };
       const int n = CHUNK < m_count ? CHUNK : m_count ;

       if ( 1 < m_count ) {
         future_type f[ CHUNK ] ;

         const int inc = ( m_count + n - 1 ) / n ;

         for ( int i = 0 ; i < n ; ++i ) {
           long begin = i * inc ;
           long count = begin + inc < m_count ? inc : m_count - begin ;
           f[i] = m_policy.task_spawn( TestTaskDependence(count,m_policy,m_accum) , Kokkos::TaskSingle );
         }

         m_count = 0 ;

         m_policy.respawn( this , m_policy.when_all( n , f ) );
       }
       else if ( 1 == m_count ) {
         Kokkos::atomic_increment( & m_accum() );
       }
    }
开发者ID:albapa,项目名称:lammps,代码行数:25,代码来源:TestTaskPolicy.hpp


示例2: create

    static KOKKOS_INLINE_FUNCTION
    future_type create(policy_type &policy, const TaskFunctorType &func) {

      future_type f ;
      // while ( f.is_null() ) {
        f = policy.task_create_team(func, _max_task_dependence);
      // }
      if ( f.is_null() ) Kokkos::abort("task_create_team FAILED, out of memory");
      return f ;
    }
开发者ID:ArchRobison,项目名称:kokkos,代码行数:10,代码来源:task_factory.hpp


示例3: runtime_error

    typename std::enable_if< ! std::is_same<policy_type,PRIORITY_POLICY>::value, std::future<typename std::result_of<F(Args...)>::type> >::type
    enqueue(F&& f, Args&&... args){
        typedef typename std::result_of<F(Args...)>::type return_type;
        // Don't allow enqueueing after stopping the pool
        if ( ! isActive.load() )
            throw std::runtime_error("enqueue on stopped ThreadPool");

        auto task = std::make_shared<std::packaged_task<return_type()>>(
            std::bind(std::forward<F>(f), std::forward<Args>(args)...) );

        std::future<return_type> result = task->get_future();
        {
            std::unique_lock<std::mutex> lock(queue_mutex);
            mTasks.push([task](){ (*task)(); });
        }
        condition.notify_one();
        return result;
    }
开发者ID:duxiuxia,项目名称:Link,代码行数:18,代码来源:ThreadPool.hpp


示例4: addDependence

 static 
 void addDependence(policy_type &policy, 
                    TaskFunctorType *after, const future_type &before) {
   policy.add_dependence(after, before);
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:5,代码来源:task_factory.hpp


示例5: clearDependence

 static  KOKKOS_INLINE_FUNCTION
 void clearDependence(policy_type &policy, TaskFunctorType *func) {
   policy.clear_dependence(func);
 }
开发者ID:ArchRobison,项目名称:kokkos,代码行数:4,代码来源:task_factory.hpp


示例6: respawn

 static
 void respawn(policy_type &policy, TaskFunctorType *func) {
   policy.respawn(func);
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:4,代码来源:task_factory.hpp


示例7: clearDependence

 static 
 void clearDependence(policy_type &policy, TaskFunctorType *func) {
   policy.clear_dependence(func);
 }
开发者ID:agrippa,项目名称:Trilinos,代码行数:4,代码来源:task_factory.hpp


示例8: spawn

 static
 void spawn(policy_type &policy, const future_type &obj) {
   policy.spawn(obj);
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:4,代码来源:task_factory.hpp


示例9: create

 static 
 future_type create(policy_type &policy, const TaskFunctorType &func) {
   return (_use_team_interface ? 
           policy.create_team(func, _max_task_dependence) : 
           policy.create     (func, _max_task_dependence)); 
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:6,代码来源:task_factory.hpp


示例10: addDependence

 static
 void addDependence(policy_type &policy, 
                    const future_type &after, const future_type &before) {
   policy.add_dependence(after, before);
 }
开发者ID:rainiscold,项目名称:trilinos,代码行数:5,代码来源:task_factory.hpp


示例11: respawn

 static KOKKOS_INLINE_FUNCTION
 void respawn(policy_type &policy, TaskFunctorType *func) {
   policy.respawn(func);
 }
开发者ID:ArchRobison,项目名称:kokkos,代码行数:4,代码来源:task_factory.hpp


示例12: spawn

 static KOKKOS_INLINE_FUNCTION
 void spawn(policy_type &policy, const future_type &obj, bool priority = false ) {
   policy.spawn(obj,priority);
 }
开发者ID:ArchRobison,项目名称:kokkos,代码行数:4,代码来源:task_factory.hpp


示例13: addDependence

 static  KOKKOS_INLINE_FUNCTION
 void addDependence(policy_type &policy, 
                    TaskFunctorType *after, const future_type &before) {
   policy.add_dependence(after, before);
 }
开发者ID:ArchRobison,项目名称:kokkos,代码行数:5,代码来源:task_factory.hpp


示例14: exception_invalid_key

 /*!
  * \brief Access cache data
  *
  * Accessor to the data (values) stored in cache. If the specified key exists in the cache, it's usage count will be touched and reference to the element is returned.
  * The data object itself is kept in the cache, so the reference will be valid until it is removed (either manually or due to cache overflow) or cache object destroyed.
  *
  * \param <_k> key to the data
  *
  * \throw  <exception_invalid_key> Thrown when non-existent key is supplied. You could use \link cache::check check member \endlink or \link cache::count count member \endlink to check cache existence prior to fetching the data
  *
  * \return constand reference to the data, mapped by the key. of type Data of course.
  *
  * \see check
  */
 const Data& fetch(const Key& _k) {
     if (!this->_check(_k)) {
         throw exception_invalid_key("Key is not in cache",_k);
     }
     _policy->touch(_k);
     return (*(_storage.find(_k))).second;
 }
开发者ID:akashihi,项目名称:stlcache,代码行数:21,代码来源:stlcache.hpp


示例15: get

 /*!
  * \brief Safe cache data access
  *
  * Accessor to the data (values) stored in cache. If the specified key exists in the cache, it's usage count will be touched
  * and reference to the element, wrapped to boost::optional  is returned.  For non-exsitent key empty boost::optional container is returned
  * The data object itself is kept in the cache, so the reference will be valid until it is removed (either manually or due to cache overflow) or cache object destroyed.
  *
  *  This function is only available if USE_BOOST_OPTIONAL macro is defined
  *
  * \param <_k> key to the data
  *
  * \return constant boost::optional wrapper, holding constant reference to the data, in case when key were in the cache,
  * or empty constant boost::optional wrapper for non-existent key.
  *
  * \see check, fetch
  */
 const boost::optional<const Data&> get(const Key& _k) throw() {
     write_lock_type l = lock.lockWrite();
     if (!this->_check(_k)) {
         return boost::optional<const Data&>();
     }
     _policy->touch(_k);
     return boost::optional<const Data&>((*(_storage.find(_k))).second);
 }
开发者ID:akashihi,项目名称:stlcache,代码行数:24,代码来源:stlcache.hpp


示例16: _erase

        size_type _erase ( const key_type& x ) throw() {
            size_type ret=_storage.erase(x);
            _policy->remove(x);

            _currEntries-=ret;

            return ret;
        }
开发者ID:akashihi,项目名称:stlcache,代码行数:8,代码来源:stlcache.hpp


示例17: insert

        /*!
         * \brief Insert element to the cache
         *
         * The cache is extended by inserting a single new element. This effectively increases the cache size. Because cache do not allow for duplicate key values, the insertion operation checks for each element inserted whether another element exists already in the container with the same key value, if so, the element is not inserted and its mapped value is not changed in any way.
         * Extension of cache could result in removal of some elements, depending of the cache fullness and used policy. It is also possible, that removal of excessive entries
         * will fail, therefore insert operation will fail too.
         *
         * \throw <exception_cache_full>  Thrown when there are no available space in the cache and policy doesn't allows removal of elements.
         * \throw <exception_invalid_key> Thrown when the policy doesn't accepts the key
         *
         * \return true if the new elemented was inserted or false if an element with the same key existed.
         */
        bool insert(Key _k, Data _d) {
            write_lock_type l = lock.lockWrite();
            while (this->_currEntries >= this->_maxEntries) {
                _victim<Key> victim=_policy->victim();
                if (!victim) {
                    throw exception_cache_full("The cache is full and no element can be expired at the moment. Remove some elements manually");
                }
                this->_erase(*victim);
            }

            _policy->insert(_k);


            bool result=_storage.insert(value_type(_k,_d)).second;
            if (result) {
                _currEntries++;
            }

            return result;
        }
开发者ID:akashihi,项目名称:stlcache,代码行数:32,代码来源:stlcache.hpp


示例18: insert_or_assign

 /*!
  * \brief Insert new element to the cache or replace value of the existing one
  *
  * Will check, whether element with the specified key exists in the map and, in case it exists, will update it's value and increase reference count of the element.
  *
  * Otherwise it will insert single new element. This effectively increases the cache size. Because cache do not allow for duplicate key values, the insertion operation checks 
  * for each element inserted whether another element exists already in the container with the same key value, if so, the element is not inserted and its mapped value is not changed in any way.
  * Extension of cache could result in removal of some elements, depending of the cache fullness and used policy. It is also possible, that removal of excessive entries
  * will fail, therefore insert operation will fail too.
  *
  * \throw <exception_cache_full>  Thrown when there are no available space in the cache and policy doesn't allows removal of elements.
  * \throw <exception_invalid_key> Thrown when the policy doesn't accepts the key
  *
  * \return true if the new elemented was inserted or false if an element with the same key existed.
  */
 bool insert_or_assign(Key _k, Data _d) {
     if(this->_storage.find(_k)==this->_storage.end()){
         this->insert(_k, _d);
         return true;
     }
     
     _policy->touch(_k);
     _storage.erase(_k);
     _storage.insert(value_type(_k,_d)).second;
     return false;
 }
开发者ID:akashihi,项目名称:stlcache,代码行数:26,代码来源:stlcache.hpp


示例19: swap

        /*!
         * \brief Swaps contents of two caches
         *
         * Exchanges the content of the cache with the content of mp, which is another cache object containing elements of the same type and using the same expiration policy.
         * Sizes may differ. Maximum number of entries may differ too.
         *
         * \param <mp> Another cache of the same type as this whose cache is swapped with that of this cache.
         *
         * \throw <exception_invalid_policy> Thrown when the policies of the caches to swap are incompatible.
         *
         * \see cache::operator=
         */
        void swap ( cache<Key,Data,Policy,Compare,Allocator>& mp ) {
            write_lock_type l = lock.lockWrite();
            _storage.swap(mp._storage);
            _policy->swap(*mp._policy);

            std::size_t m=this->_maxEntries;
            this->_maxEntries=mp._maxEntries;
            mp._maxEntries=m;

            this->_currEntries=this->_size();
            mp._currEntries=mp.size();
        }
开发者ID:akashihi,项目名称:stlcache,代码行数:24,代码来源:stlcache.hpp


示例20: touch

 /*!
  * \brief Increase usage count for entry
  *
  *  Touches an entry in cache, simulating access to it. Usefull to promote (or devote, depending on policy) item in the cache, reducing(or increasing)
  *  risk for expiration for it.
  *
  *  \param _k key to touch
  *
  */
 void touch(const Key& _k) {
     write_lock_type l = lock.lockWrite();
     _policy->touch(_k);
 }
开发者ID:akashihi,项目名称:stlcache,代码行数:13,代码来源:stlcache.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ poly类代码示例发布时间:2022-05-31
下一篇:
C++ point_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap