cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / bindings / python / bt2 / bt2 / interrupter.py
1 # SPDX-License-Identifier: MIT
2 #
3 # Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
4
5 from bt2 import error as bt2_error
6 from bt2 import object as bt2_object
7 from bt2 import native_bt
8
9
10 class Interrupter(bt2_object._SharedObject):
11 @staticmethod
12 def _get_ref(ptr):
13 native_bt.interrupter_get_ref(ptr)
14
15 @staticmethod
16 def _put_ref(ptr):
17 native_bt.interrupter_put_ref(ptr)
18
19 def __init__(self):
20 ptr = native_bt.interrupter_create()
21
22 if ptr is None:
23 raise bt2_error._MemoryError("cannot create interrupter object")
24
25 super().__init__(ptr)
26
27 @property
28 def is_set(self):
29 return bool(native_bt.interrupter_is_set(self._ptr))
30
31 def __bool__(self):
32 return self.is_set
33
34 def set(self):
35 native_bt.interrupter_set(self._ptr)
36
37 def reset(self):
38 native_bt.interrupter_reset(self._ptr)
This page took 0.030112 seconds and 4 git commands to generate.