python: make all _get_ref/_put_ref proper static methods
[babeltrace.git] / src / bindings / python / bt2 / bt2 / interrupter.py
CommitLineData
0235b0db 1# SPDX-License-Identifier: MIT
1e920353
PP
2#
3# Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
1e920353
PP
4
5from bt2 import native_bt, object
786c8e14 6import bt2
1e920353
PP
7
8
9class Interrupter(object._SharedObject):
9dee90bd
SM
10 @staticmethod
11 def _get_ref(ptr):
12 native_bt.interrupter_get_ref(ptr)
13
14 @staticmethod
15 def _put_ref(ptr):
16 native_bt.interrupter_put_ref(ptr)
1e920353
PP
17
18 def __init__(self):
19 ptr = native_bt.interrupter_create()
20
21 if ptr is None:
f5567ea8 22 raise bt2._MemoryError("cannot create interrupter object")
1e920353
PP
23
24 super().__init__(ptr)
25
26 @property
27 def is_set(self):
28 return bool(native_bt.interrupter_is_set(self._ptr))
29
30 def __bool__(self):
31 return self.is_set
32
33 def set(self):
34 native_bt.interrupter_set(self._ptr)
35
36 def reset(self):
37 native_bt.interrupter_reset(self._ptr)
This page took 0.054952 seconds and 4 git commands to generate.