本文整理汇总了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());
}
示例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);
}
}
示例3: ThreadRunner
void* ThreadRunner(void*) {
int k;
for (k = 0; k < 100000000; k++) {
sem_wait(&semaphore);
x.Increment();
sem_post(&semaphore);
}
}
示例4: ThreadRunner
void* ThreadRunner(void*){
int k;
for (k=0;k<100000000;k++){
pthread_mutex_lock(&mutex);
x.Increment();
pthread_mutex_unlock(&mutex);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
}