mirror of
https://github.com/Z3Prover/z3
synced 2025-05-01 04:45:52 +00:00
simplify timeout mechanism and fix race conditions there
This commit is contained in:
parent
f3cd7d646d
commit
a76c0fbbfb
2 changed files with 15 additions and 18 deletions
|
@ -19,7 +19,6 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include "util/z3_omp.h"
|
||||
#include "util/util.h"
|
||||
#include "util/timeout.h"
|
||||
#include "util/error_codes.h"
|
||||
|
@ -34,26 +33,21 @@ namespace {
|
|||
class g_timeout_eh : public event_handler {
|
||||
public:
|
||||
void operator()(event_handler_caller_t caller_id) override {
|
||||
#pragma omp critical (g_timeout_cs)
|
||||
{
|
||||
std::cout << "timeout\n";
|
||||
m_caller_id = caller_id;
|
||||
if (g_on_timeout)
|
||||
g_on_timeout();
|
||||
if (g_timeout)
|
||||
delete g_timeout;
|
||||
g_timeout = nullptr;
|
||||
throw z3_error(ERR_TIMEOUT);
|
||||
}
|
||||
std::cout << "timeout\n";
|
||||
m_caller_id = caller_id;
|
||||
if (g_on_timeout)
|
||||
g_on_timeout();
|
||||
throw z3_error(ERR_TIMEOUT);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void set_timeout(long ms) {
|
||||
if (g_timeout)
|
||||
delete g_timeout;
|
||||
static g_timeout_eh eh;
|
||||
|
||||
g_timeout = new scoped_timer(ms, new g_timeout_eh());
|
||||
void set_timeout(long ms) {
|
||||
SASSERT(!g_timeout);
|
||||
// this is leaked, but since it's only used in the shell, it's ok
|
||||
g_timeout = new scoped_timer(ms, &eh);
|
||||
}
|
||||
|
||||
void register_on_timeout_proc(void (*proc)()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue