mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
pfor
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9262908ebb
commit
59330b3855
5 changed files with 23 additions and 15 deletions
|
@ -18,9 +18,6 @@ Revision History:
|
|||
--*/
|
||||
#include "util/rlimit.h"
|
||||
#include "util/common_msgs.h"
|
||||
#include <mutex>
|
||||
|
||||
static std::mutex g_reslimit_cancel;
|
||||
|
||||
|
||||
reslimit::reslimit():
|
||||
|
@ -73,34 +70,34 @@ char const* reslimit::get_cancel_msg() const {
|
|||
}
|
||||
|
||||
void reslimit::push_child(reslimit* r) {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
m_children.push_back(r);
|
||||
}
|
||||
|
||||
void reslimit::pop_child() {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
m_children.pop_back();
|
||||
}
|
||||
|
||||
void reslimit::cancel() {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
set_cancel(m_cancel+1);
|
||||
}
|
||||
|
||||
|
||||
void reslimit::reset_cancel() {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
set_cancel(0);
|
||||
}
|
||||
|
||||
void reslimit::inc_cancel() {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
set_cancel(m_cancel+1);
|
||||
}
|
||||
|
||||
|
||||
void reslimit::dec_cancel() {
|
||||
std::lock_guard<std::mutex> lock(g_reslimit_cancel);
|
||||
std::lock_guard<std::mutex> lock(m_mux);
|
||||
if (m_cancel > 0) {
|
||||
set_cancel(m_cancel-1);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ Revision History:
|
|||
#ifndef RLIMIT_H_
|
||||
#define RLIMIT_H_
|
||||
|
||||
#include <mutex>
|
||||
#include "util/vector.h"
|
||||
|
||||
class reslimit {
|
||||
|
@ -28,12 +29,14 @@ class reslimit {
|
|||
uint64_t m_limit;
|
||||
svector<uint64_t> m_limits;
|
||||
ptr_vector<reslimit> m_children;
|
||||
std::mutex m_mux;
|
||||
|
||||
void set_cancel(unsigned f);
|
||||
friend class scoped_suspend_rlimit;
|
||||
|
||||
public:
|
||||
reslimit();
|
||||
~reslimit() {}
|
||||
void push(unsigned delta_limit);
|
||||
void pop();
|
||||
void push_child(reslimit* r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue