Skip to content
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

Replace session pointer with refcount #320

Closed
wants to merge 27 commits into from

Conversation

jean-roland
Copy link
Contributor

@jean-roland jean-roland commented Jan 17, 2024

The entities session publisher, subscriber and queryables were sharing ownership of the same _z_session_t pointer, this caused issues like #312. This PR replaces the session pointer with a refcounter on the session pointer.

Had to modify how the refcount implementation was handled:

  • Restricted the thread unsafe one to single thread mode only
  • Added a c99 gcc only implementation

And renamed pointer.h / _sptr_t to refcount.h / _rc_t

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cppcheck (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

#define _Z_REFCOUNT_DEFINE(name, type) \
typedef struct name##_rc_t { \
type##_t *ptr; \
_z_atomic(unsigned int) * _cnt; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define a struct name##_rc_inner_t {type##_t value; _z_atomic(unsigned int) _cnt;}; and have a single pointer to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting suggestion.

@jean-roland
Copy link
Contributor Author

Have to close this one with the main branch renaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants