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