base
¶
Base classes for reference counting.
Classes:
-
NativeHandle
–A base class for wrappers around otherwise "unmanaged" resources e.g. in a native library.
-
ReferenceCounter
–A base class for reference counters.
NativeHandle
¶
Bases: ReferenceCounter
A base class for wrappers around otherwise "unmanaged" resources e.g. in a native library.
Attributes:
-
_handle
(object
) –The handle (e.g. cffi pointer) to the native resource.
-
_finalizing
(bool
) –a flag telling whether this object is in its deletion phase. This has a use in some advanced cases with reverse callback, possibly not relevant in Python.
Parameters:
-
handle
(object
, default:None
) –The handle (e.g. cffi pointer) to the native resource.
-
prior_ref_count
(int
, default:0
) –the initial reference count. Default 0 if this NativeHandle is sole responsible for the lifecycle of the resource.
Methods:
-
add_ref
–Manually increment the reference count.
-
decrement_ref
–Manually increment the reference count.
Attributes:
-
reference_count
(int
) –Get the current reference count.
Source code in src/refcount/base.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
add_ref
¶
add_ref() -> None
Manually increment the reference count.
Users usually have no need to call this method. They may have to if they manage cases where one native handle wrapper uses another wrapper (and its underlying resource).
Source code in src/refcount/base.py
26 27 28 29 30 31 32 |
|
decrement_ref
¶
decrement_ref() -> None
Manually increment the reference count.
Users usually have no need to call this method. They may have to if they manage cases where one native handle wrapper uses another wrapper (and its underlying resource).
Source code in src/refcount/base.py
34 35 36 37 38 39 40 |
|
ReferenceCounter
¶
ReferenceCounter(prior_ref_count: int = 0)
A base class for reference counters.
Attributes:
-
reference_count
(int
) –property getter, reference count
Parameters:
-
prior_ref_count
(int
, default:0
) –the initial reference count. Default 0 if this object is sole responsible for the lifecycle of the resource.
Methods:
-
add_ref
–Manually increment the reference count.
-
decrement_ref
–Manually increment the reference count.
Attributes:
-
reference_count
(int
) –Get the current reference count.
Source code in src/refcount/base.py
13 14 15 16 17 18 19 |
|
add_ref
¶
add_ref() -> None
Manually increment the reference count.
Users usually have no need to call this method. They may have to if they manage cases where one native handle wrapper uses another wrapper (and its underlying resource).
Source code in src/refcount/base.py
26 27 28 29 30 31 32 |
|
decrement_ref
¶
decrement_ref() -> None
Manually increment the reference count.
Users usually have no need to call this method. They may have to if they manage cases where one native handle wrapper uses another wrapper (and its underlying resource).
Source code in src/refcount/base.py
34 35 36 37 38 39 40 |
|