3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-04 18:30:24 +00:00

#7418 - circumvent use of timer threads to make WASM integration of z3 easier

The scoped_timer uses a std::therad. Spawning this thread fails in cases of WASM.
Instead of adapting builds and using async features at the level of WASM and the client, we expose a specialized version of z3 that doesn't use threads at all, neither for solvers nor for timers.
The tradeoff is that the periodic poll that checks for timeout directly queries the global clock each time.
We characterize it as based on polling.
This commit is contained in:
Nikolaj Bjorner 2024-11-21 11:20:05 -08:00
parent 94f0aff47f
commit 71bad7159b
8 changed files with 124 additions and 31 deletions

View file

@ -25,11 +25,12 @@ Revision History:
*/
template<typename T>
class cancel_eh : public event_handler {
bool m_canceled;
bool m_canceled = false;
bool m_auto_cancel = false;
T & m_obj;
public:
cancel_eh(T & o): m_canceled(false), m_obj(o) {}
~cancel_eh() override { if (m_canceled) m_obj.dec_cancel(); }
cancel_eh(T & o): m_obj(o) {}
~cancel_eh() override { if (m_canceled) m_obj.dec_cancel(); if (m_auto_cancel) m_obj.auto_cancel(); }
void operator()(event_handler_caller_t caller_id) override {
if (!m_canceled) {
m_caller_id = caller_id;
@ -39,5 +40,7 @@ public:
}
bool canceled() const { return m_canceled; }
void reset() { m_canceled = false; }
T& t() { return m_obj; }
void set_auto_cancel() { m_auto_cancel = true; }
};