Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Implement pushing/popping a thread default main context in a panic-sa… #309

Closed
wants to merge 1 commit into from
Closed

Implement pushing/popping a thread default main context in a panic-sa… #309

wants to merge 1 commit into from

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Apr 8, 2018

…fe way

Not sure about the name of the struct. And maybe we need to somehow prevent it from implementing Send.

@ghost
Copy link

ghost commented Apr 8, 2018

What exactly could panic here?

This approach still allows one to cross the lifetimes of different contexts.
Using a method that accepts a closure would eliminate the issue (as long one
does not call push / pop, manually). Maybe something alone the lines of:

ctx.with_thread_default(|| {
  ...
});

with_thread_default_context(ctx, || {
  ...  
});

thread_default(ctx, || {
  ...  
});

@sdroege
Copy link
Member Author

sdroege commented Apr 8, 2018

What exactly could panic here?

If something between push and pop panics, pop would never happen

You're right though, it's possible to mess up the order here still and it would ideally have to be done with a closure like you suggest. Thanks!

@sdroege
Copy link
Member Author

sdroege commented Apr 9, 2018

The question then is whether we want that or if it's too annoying to use. Opinions?

@sdroege
Copy link
Member Author

sdroege commented Apr 18, 2018

Closing in favour of #319

@sdroege sdroege closed this Apr 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant