本文整理汇总了C++中Counter::decrement方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::decrement方法的具体用法?C++ Counter::decrement怎么用?C++ Counter::decrement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::decrement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decrement
void decrement(){
std::lock_guard<std::mutex> guard(mutex);
try {
counter.decrement();
} catch (std::exception& e) {
std::cout << "error caught"<< std::endl;
}
}
示例2: force_unique
void force_unique() {
if (counter->getCount() > 1) {
counter->decrement();
counter = new Counter();
counter->increment();
Core *new_core = new Core(*(this->core));
this->core = new_core;
}
}
示例3: destroy
void destroy() {
if (counter->decrement() == 0) {
if (ptr == nullptr) {
return;
}
delete ptr;
delete counter;
}
}
示例4: destroy
void destroy() {
if (counter->decrement() == 0) {
if (data == nullptr) {
return;
}
delete data;
delete counter;
len = 0;
}
}
示例5: force_unique
void force_unique() {
if (counter->getCount() > 1) {
char * temp = data;
data = new char[len + 1];
strcpy(data, temp);
counter->decrement();
counter = new Counter();
counter->increment();
}
}
示例6: decrement
void decrement(){
mutex.lock();
try {
counter.decrement();
} catch (std::string e){
mutex.unlock();
throw e;
}
mutex.unlock();
}
示例7: decrement
void decrement() {
std::lock_guard<std::mutex> guard(mutex);
counter.decrement();
}
示例8: destroy
void destroy() {
if (counter->decrement() == 0) {
delete core;
delete counter;
}
}
示例9: decrement
void decrement(){
std::lock_guard<std::mutex> guar(mutex);
counter.decrement();
//mutex.unlock();
}