let's try console

This commit is contained in:
tildearrow 2023-02-14 01:02:35 -05:00
parent 9cdc330a48
commit 8313d0f518
3 changed files with 33 additions and 4 deletions

View file

@ -21,6 +21,10 @@
#ifndef ARRAY_H
#define ARRAY_H
#include <mutex>
extern std::mutex counterOps;
/**
* Counter.
*/
@ -59,7 +63,7 @@ public:
x(p.x),
y(p.y) { count->increase(); }
~matrix() { if (count->decrease() == 0) { delete count; delete [] data; } }
~matrix() { counterOps.lock(); if (count->decrease() == 0) { delete count; delete [] data; } counterOps.unlock(); }
unsigned int length() const { return x * y; }