cloud-sat/workers/clause.hpp

33 lines
685 B
C++
Raw Normal View History

2022-09-08 13:54:29 +08:00
#ifndef _clause_hpp_INCLUDED
#define _clause_hpp_INCLUDED
struct clause_store {
int size, lbd;
int *data;
2022-09-15 10:31:41 +08:00
std::atomic<int> refs;
2022-09-08 13:54:29 +08:00
clause_store(int sz) {
size = sz;
data = (int*) malloc(sizeof(int) * sz);
lbd = 0;
refs = 1;
}
2022-09-15 10:31:41 +08:00
void increase_refs(int inc) {
refs += inc;
}
bool free_clause() {
2022-09-08 13:54:29 +08:00
int ref = refs.fetch_sub(1);
2022-09-15 10:31:41 +08:00
if (ref <= 1) {
// for (int i = 0; i < size; i++)
// printf("%d ", data[i]);
// puts("");
2022-09-08 13:54:29 +08:00
free(data);
2022-09-15 10:31:41 +08:00
return true;
}
return false;
}
~clause_store() {
puts("free");
2022-09-08 13:54:29 +08:00
}
};
#endif