Move to kernel style SPDX license identifiers
[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 native_bt, object
6 import bt2
7
8
9 class Interrupter(object._SharedObject):
10 _get_ref = staticmethod(native_bt.interrupter_get_ref)
11 _put_ref = staticmethod(native_bt.interrupter_put_ref)
12
13 def __init__(self):
14 ptr = native_bt.interrupter_create()
15
16 if ptr is None:
17 raise bt2._MemoryError('cannot create interrupter object')
18
19 super().__init__(ptr)
20
21 @property
22 def is_set(self):
23 return bool(native_bt.interrupter_is_set(self._ptr))
24
25 def __bool__(self):
26 return self.is_set
27
28 def set(self):
29 native_bt.interrupter_set(self._ptr)
30
31 def reset(self):
32 native_bt.interrupter_reset(self._ptr)
This page took 0.033351 seconds and 4 git commands to generate.