python: make all _get_ref/_put_ref proper static methods
[babeltrace.git] / src / bindings / python / bt2 / bt2 / interrupter.py
... / ...
CommitLineData
1# SPDX-License-Identifier: MIT
2#
3# Copyright (c) 2019 Philippe Proulx <pproulx@efficios.com>
4
5from bt2 import native_bt, object
6import bt2
7
8
9class Interrupter(object._SharedObject):
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)
17
18 def __init__(self):
19 ptr = native_bt.interrupter_create()
20
21 if ptr is None:
22 raise bt2._MemoryError("cannot create interrupter object")
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.023225 seconds and 4 git commands to generate.