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

Inefficiency in the CriticalSection API #7

Closed
TethysSvensson opened this issue Jun 2, 2018 · 0 comments · Fixed by #20
Closed

Inefficiency in the CriticalSection API #7

TethysSvensson opened this issue Jun 2, 2018 · 0 comments · Fixed by #20

Comments

@TethysSvensson
Copy link

It seems inefficient to pass around a &'a CriticalSection, since reference to zero-sized types are not themselves zero-sized in rust. In a lot of cases, this would be compiled out, but it is not guaranteed.

It would be better if CriticalSection was defined like this:

struct CriticalSection<'a> {
    _0: PhantomData<&'a ()>,
}

Instead of passing &'a CriticalSection you would then pass a CriticalSection<'a> around. This would have the same purpose

@jonas-schievink jonas-schievink mentioned this issue Jan 9, 2020
7 tasks
bors bot added a commit that referenced this issue Jan 28, 2020
20: Use CriticalSection<'cs> instead of &'cs CriticalSection. r=jonas-schievink a=m-ou-se

Fixes #7.

A `CriticalSection<'cs>` has a size of zero
unlike a `&'cs CriticalSection`, which has the size of a pointer.

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
@bors bors bot closed this as completed in 23156b0 Jan 28, 2020
@bors bors bot closed this as completed in #20 Jan 28, 2020
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 a pull request may close this issue.

1 participant