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


C++ Atomic::value方法代码示例

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


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

示例1: __atomic_compare_exchange_n

inline bool Atomic<T>::cswap ( const Atomic<T> &oldval, const Atomic<T> &newval )
{
#ifdef HAVE_NEW_GCC_ATOMIC_OPS
   // FIXME: The atomics passed are const
   T* oldv = const_cast<T*>(&oldval._value);
   T* newv = const_cast<T*>(&newval._value);
   return __atomic_compare_exchange_n( &_value, oldv, newv,
         /* weak */ false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE );
#else
   return __sync_bool_compare_and_swap ( &_value, oldval.value(), newval.value() );
#endif
}
开发者ID:osubasi,项目名称:CRC-in-Nanox,代码行数:12,代码来源:atomic.hpp

示例2: main

int main ( int argc, char **argv )
{
   int i;
   bool check = true;

   main__loop_1_data_t _loop_data;

   A = 0;

   WD *wg = getMyThreadSafe()->getCurrentWD(); 
   for ( i = 0; i < NUM_ITERS; i++ ) {
      
      // If we're done processing half of the dataset
      if ( i == NUM_ITERS/2 ) {
         // Stop scheduler
         sys.stopScheduler();
      }
      
      // Work descriptor creation
      WD * wd = new WD( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t), ( void * ) &_loop_data );
      wd->setPriority( 100 );

      // Work Group affiliation
      wg->addWork( *wd );

      // Work submission
      sys.submit( *wd );
      
      if ( i == ( NUM_ITERS/2 + 5 ) ){
         // Keep going
         sys.startScheduler();
      }
   }
   // barrier (kind of)
   wg->waitCompletion();
   

   /*
    * How can we be sure the test passed? Each task increments A. If we run N
    * tasks, A should be equal to N.
    * If it's less than N, that'd mean the scheduler lost something.
    */
   if ( A.value() != NUM_ITERS ) check = false;

   if ( check ) {
      fprintf(stderr, "%s : %s\n", argv[0], "successful");
      return 0;
   }
   else {
      fprintf(stderr, "%s: %s\n", argv[0], "unsuccessful");
      return -1;
   }
}
开发者ID:osubasi,项目名称:CRC-in-Nanox,代码行数:53,代码来源:scheduler_run_stop_run.cpp

示例3: main

int main ( int argc, char **argv )
{
   int i;
   bool check = true;

   main__loop_1_data_t _loop_data;

   // Repeat the test NUM_RUNS times
   for ( int testNumber = 0; testNumber < NUM_RUNS; ++testNumber ) {
      A = 0;
   
      WG *wg = getMyThreadSafe()->getCurrentWD();   
      // Stop scheduler
      sys.stopScheduler();
      // increment variable
      for ( i = 0; i < NUM_ITERS; i++ ) {
         // Work descriptor creation
         WD * wd = new WD( new SMPDD( main__loop_1 ), sizeof( _loop_data ), __alignof__(nanos_loop_info_t), ( void * ) &_loop_data );
         wd->setPriority( 100 );
   
         // Work Group affiliation
         wg->addWork( *wd );
   
         // Work submission
         sys.submit( *wd );
      }
      // Re-enable the scheduler
      sys.startScheduler();
      // barrier (kind of)
      wg->waitCompletion();
      
   
      /*
       * The verification criteria is that A is equal to the number of tasks
       * run. Should A be lower, that would indicate that not all tasks
       * successfuly finished.
       */
      if ( A.value() != NUM_ITERS ) check = false;
   }

   if ( check ) {
      fprintf(stderr, "%s : %s\n", argv[0], "successful");
      return 0;
   }
   else {
      fprintf(stderr, "%s: %s\n", argv[0], "unsuccessful");
      return -1;
   }
}
开发者ID:robbriggs,项目名称:masters-project-nanosxx,代码行数:49,代码来源:scheduler_stop.cpp

示例4: value

inline bool Atomic<T>::operator>= ( const Atomic<T> &val )
{
   return value() >= val.value();
}
开发者ID:osubasi,项目名称:CRC-in-Nanox,代码行数:4,代码来源:atomic.hpp

示例5: subAndFetch

inline T Atomic<T>::operator-= ( const Atomic<T> &val )
{
   return subAndFetch(val.value());
}
开发者ID:osubasi,项目名称:CRC-in-Nanox,代码行数:4,代码来源:atomic.hpp

示例6: addAndFetch

inline T Atomic<T>::operator+= ( const Atomic<T> &val )
{
   return addAndFetch(val.value());
}
开发者ID:osubasi,项目名称:CRC-in-Nanox,代码行数:4,代码来源:atomic.hpp


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