MACRO
OMNI_DISPOSE_EVENT
- If defined, classes within the library will have a disposing event.
SYNOPSIS top
If this macro is defined, then any classes in the library that can be instantiated (e.g. non-abstract classes and non-POD types) will have an
If this macro is defined, then any classes in the library that can be instantiated (e.g. non-abstract classes and non-POD types) will have an
omni::event
as a member that will be raised when the objects destructor is called.
DESCRIPTION top
Classes in C++ are deterministic by scope lifetime in that they have a start (constructor) and end (destructor). To this, if this macro is defined then any classes that can be instantiated within the library will have an
The output of the above example would be:
Where
Classes in C++ are deterministic by scope lifetime in that they have a start (constructor) and end (destructor). To this, if this macro is defined then any classes that can be instantiated within the library will have an
omni::event
called disposing
that will be invoked upon destruction of the Omni class. Example:static bool some_condition = false; void thread_disposed(const omni::thread* sender) { std::cout << "Thread " << sender->id() << " is being destroyed." << std::endl; some_condition = true; sender->join(); } void thread_function() { do { // thread code ... } while (!some_condition); } void some_function() { omni::thread t(&thread_function); t.disposing += &thread_disposed; t.start(); } int main() { std::cout << "before" << std::endl; some_function() // thread destructor called when scope is left from // some_function, thus the disposed function will // be called calling our attached thread_disposed function std::cout << "after" << std::endl; }
before //...whatever from the thread code... Thread 0x00011 is being destroyed. after
0x00011
would be the thread id given by the system.
CONSIDERATIONS top
If you enable this option, any classes that utilize this functionality will increase by
If you enable this option, any classes that utilize this functionality will increase by
sizeof(omni::event1)
.