-
Notifications
You must be signed in to change notification settings - Fork 19
Rework the parsec_object_t system. #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The new destructor need to return a continuation value, 0 if the chain of destructors will contiune to be called, 1 if no other destructors shall be called on this object. As a result, we can now recycle parsec_objects for as long as they are correcty reinitialized twice. The first time, when the object is stored in some internal cache (in order to be able to properly chain it) and the second time before returning a newly allocated object back to the user. Signed-off-by: George Bosilca <[email protected]>
devreal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good solution 👍 Little worried about changing the ABI but I guess TTG is the only external user we know?
Also, just to document this: the life-cycle of an object would look like this:
struct derived_t { lifo_elem_t super; ... };
ALLOC(obj)
-> [
-> CONSTRUCT(obj, derived_t)
-> USE(obj)
-> RELEASE(obj)
// inside the destructor of derived_t
-> CONSTRUCT(obj, lifo_elem_t)
-> PUSH(lifo, obj) // stash away
// destructor of derived_t returns 1
-> POP(lifo, obj) // get it back
-> DESTRUCT(obj) // destruct the lifo_elem_t
]* // rinse and repeat
-> FREE(obj) // finally release the memory
It's a bit strange to construct an object in memory where the previous object was not destroyed (i.e., the lifo_elem_t was never released and we're overwriting it). I guess that is fine as long as the base class does not hold any resources that must be released before reconstructing it.
|
We need to think about this a little longer, as the solution proposed here does not allow the object to be forcefully released. The objects could implement their own logic in the destructor that will always release the object if we are in some final state (aka. during parsec_fini), but this is error prone, and does not account for calls to OBJ_DESTRUCT. |
The reason I had the extra |
|
Correct, the object is not in a correct state and shall not be released unless (re)constructed. But is does not have to be constructed in order to be added to the lifo, because the magic is only tested during release. |
|
All these approaches have the same underlying problem: they have no clear way to release the objects (not put them back into a list but really free them). |
|
We did #731 instead. This one has some extra features but we don't use them atm. |
The new destructor need to return a continuation value, 0 if the chain of destructors will continue to be called, 1 if no other destructors shall be called on this object. As a result, we can now recycle parsec_objects for as long as they are correctly initialized twice. The first time, when the object is stored in some internal cache (in order to be able to properly chain it) and the second time before returning a newly allocated object back to the user.
Fixes #724.
Per @devreal suggestion here is a use case: