ObserverGuard#
- class carb.eventdispatcher.ObserverGuard#
Bases:
pybind11_object
ObserverGuard.
Lifetime control for a registered observer. Unregister the observer by calling the reset() function or allowing the object to be collected.
Methods
Attributes
Sets or gets the enabled state of an observer.
gets the name of the observer.
Sets or gets the integer order of the observer.
- __init__(*args, **kwargs)#
- reset( ) None #
Explicitly stops an observer.
Having this object collected has the same effect, implicitly.
This is safe to perform while dispatching.
Since observers can be in use by this thread or any thread, this function is carefully synchronized with all other Event Dispatcher operations.
During `reset()`, further calls to the observer are prevented, even if other threads are currently dispatching an event that would be observed by the observer in question.
If any other thread is currently calling the observer in question, `reset()` will wait until all other threads have left the observer callback function.
If the observer function is not in the backtrace of the current thread, the observer function is immediately released.
If the observer function is in the backtrace of the current thread, `reset()` will return without waiting and without releasing the observer callback. Instead, releasing the function will be performed when the `dispatch_event()` call in the current thread finishes.
When `reset()` returns, it is guaranteed that the observer callback function will no longer be called and all calls to it have completed (except if the calling thread is dispatching).
- property enabled#
Sets or gets the enabled state of an observer.
- property name#
gets the name of the observer.
- Type:
Read-only
- property order#
Sets or gets the integer order of the observer.