3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 05:18:44 +00:00
z3/src/util/scoped_ctrl_c.h
Nuno Lopes 83e34638e6 add support to build with MSVC /Gr (fastcall mode for x86)
not enabled by default nor exposed at the moment
2016-03-24 15:39:18 +00:00

44 lines
917 B
C++

/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
scoped_ctrl_c.h
Abstract:
Scoped control-c handler.
Author:
Leonardo de Moura (leonardo) 2011-04-27.
Revision History:
--*/
#ifndef SCOPED_CTRL_C_H_
#define SCOPED_CTRL_C_H_
#include"event_handler.h"
#include"util.h"
struct scoped_ctrl_c {
event_handler & m_cancel_eh;
bool m_first;
bool m_once;
bool m_enabled;
void (STD_CALL *m_old_handler)(int);
scoped_ctrl_c * m_old_scoped_ctrl_c;
static scoped_ctrl_c * g_obj;
static void STD_CALL on_ctrl_c(int);
public:
// If once == true, then the cancel_eh is invoked only at the first Ctrl-C.
// The next time, the old signal handler will take over.
// if enabled == false, then scoped_ctrl_c is a noop
scoped_ctrl_c(event_handler & eh, bool once=true, bool enabled=true);
~scoped_ctrl_c();
void reset() { m_first = true; }
};
#endif