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


C++ Counter::Increment方法代码示例

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


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

示例1: TEST_F

TEST_F(TestMemFnPointerSample, All) {
    Counter counter;
    CountLater countLater;

    int expected = 0;
    EXPECT_EQ(expected, counter.Get());

    counter.Increment();
    ++expected;
    EXPECT_EQ(expected, counter.Get());
    counter.Decrement();
    counter.Decrement();
    expected -= 2;
    EXPECT_EQ(expected, counter.Get());

    countLater.Execute();
    EXPECT_EQ(expected, counter.Get());

    countLater.ExecuteLater(&counter, &Counter::Decrement);
    EXPECT_EQ(expected, counter.Get());
    --expected;
    for(int i=0; i<2; ++i) {
        countLater.Execute();
        EXPECT_EQ(expected, counter.Get());
    }

    countLater.ExecuteLater(&counter, &Counter::Increment);
    EXPECT_EQ(expected, counter.Get());
    countLater.ExecuteLater(&counter, &Counter::Increment);
    ++expected;
    EXPECT_EQ(expected, counter.Get());
}
开发者ID:zettsu-t,项目名称:cppMockgen,代码行数:32,代码来源:mockgenSampleTestBody.cpp

示例2: ThreadRunner

void* ThreadRunner(void* t){
    int k;
    unsigned int seed=0;
    for (k=0;k< *(int*)t ;k++){
        x.Increment(double(rand_r(&seed))/RAND_MAX,double(rand_r(&seed))/RAND_MAX);
    }
}
开发者ID:Microsheep,项目名称:NCTU_OS_2015,代码行数:7,代码来源:base.cpp

示例3: ThreadRunner

void* ThreadRunner(void*) {
    int k;
    for (k = 0; k < 100000000; k++) {
        sem_wait(&semaphore);
        x.Increment();
        sem_post(&semaphore);
    }
}
开发者ID:CliffYang,项目名称:Operating-System,代码行数:8,代码来源:sem.cpp

示例4: ThreadRunner

void* ThreadRunner(void*){
    int k;
    for (k=0;k<100000000;k++){
        pthread_mutex_lock(&mutex);
        x.Increment();
        pthread_mutex_unlock(&mutex);
    }
}
开发者ID:Microsheep,项目名称:NCTU_OS_2015,代码行数:8,代码来源:mutex.cpp

示例5: ThreadRunner

void* ThreadRunner(void*){
    for(int k = 0 ; k < 100000000 ; k++){
        pthread_spin_lock(&m_spinlock);
        x.Increment();
        pthread_spin_unlock(&m_spinlock);
    }
    return NULL;
}
开发者ID:allenwhale,项目名称:OS,代码行数:8,代码来源:spinlock.cpp

示例6: main

int main() {
  Counter i;
  std::cout << "The value of i is " << i.GetItsVal() << std::endl;
  i.Increment();
  std::cout << "The value of i is " << i.GetItsVal() << std::endl;
  ++i;
  std::cout << "The value of i is " << i.GetItsVal() << std::endl;
  return 0;
}
开发者ID:MiltonStanley,项目名称:CPP_In_21_Days,代码行数:9,代码来源:10_8.cpp

示例7:

void *ThreadRunner(void*) {
	//long long each = 300000000/threadNum;
    for (int k = 0; k < 100000000; ++k) {
        sem_wait(&sem);
        x.Increment();
        sem_post(&sem);
    }
    pthread_exit(NULL);
}
开发者ID:easydaniel,项目名称:OperatingSystem,代码行数:9,代码来源:sem.cpp

示例8: ThreadRunner

void* ThreadRunner(void*){
    long int num = total_number_of_points / NUMTHD;
    double x, y;
    for(int i = 0; i < num; i++){
        x = GetRand();
        y = GetRand();
        if(x*x + y*y <= 1){
	    pthread_mutex_lock(&mutex);
            CT.Increment();
            pthread_mutex_unlock(&mutex);
        }
    }
}
开发者ID:CliffYang,项目名称:Operating-System,代码行数:13,代码来源:pi_lock.cpp

示例9: main

int main()
{
   Counter i;
   cout << "The value of i is " << i.GetItsVal() << endl;
   i.Increment();
   cout << "The value of i is " << i.GetItsVal() << endl;
   ++i;
   cout << "The value of i is " << i.GetItsVal() << endl;
   Counter a = i++;
   cout << "The value of a: " << a.GetItsVal()<<endl;
   ++a;
   cout << " and a: " << a.GetItsVal() << endl;
   cout<<"address of i is: "<<&i<<endl;
   cout<<"address of a is: "<<&a<<endl;
   return 0;
}
开发者ID:aooaboob,项目名称:CPP,代码行数:16,代码来源:rator_overloading.cpp

示例10: task1

void task1(void *pvParameters)
{
    Counter local_counter = Counter(12);
    Counter *new_counter = new Counter(24);
    while(1) {
        Counter *counter = NULL;
        switch(rand() % 3) {
        case 0:
            counter = &local_counter;
            break;
        case 1:
            counter = &static_counter;
            break;
        default:
            counter = new_counter;
            break;
        }
        counter->Increment();
        printf("local counter %d static counter %d newly allocated counter %d\r\n", local_counter.getCount(),
               static_counter.getCount(), new_counter->getCount());
        vTaskDelay(100);
    }
}
开发者ID:baden,项目名称:esp-open-rtos,代码行数:23,代码来源:simple.cpp


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