void decrement(){ std::lock_guard<std::mutex> guard(mutex); try { counter.decrement(); } catch (std::exception& e) { std::cout << "error caught"<< std::endl; } }
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; } }
void destroy() { if (counter->decrement() == 0) { if (ptr == nullptr) { return; } delete ptr; delete counter; } }
void destroy() { if (counter->decrement() == 0) { if (data == nullptr) { return; } delete data; delete counter; len = 0; } }
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(); } }
void decrement(){ mutex.lock(); try { counter.decrement(); } catch (std::string e){ mutex.unlock(); throw e; } mutex.unlock(); }
void decrement() { std::lock_guard<std::mutex> guard(mutex); counter.decrement(); }
void destroy() { if (counter->decrement() == 0) { delete core; delete counter; } }
void decrement(){ mutex.lock(); counter.decrement(); mutex.unlock(); }
void decrement(){ std::lock_guard<std::mutex> guar(mutex); counter.decrement(); //mutex.unlock(); }