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


C++ policy_type类代码示例

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


在下文中一共展示了policy_type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例13: 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

示例14: _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

示例15: 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


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