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

An unused async_scope can't be destroyed #641

Open
glebov-andrey opened this issue Nov 5, 2024 · 1 comment
Open

An unused async_scope can't be destroyed #641

glebov-andrey opened this issue Nov 5, 2024 · 1 comment

Comments

@glebov-andrey
Copy link

Creating and destroying a unifex::v2::async_scope without using it for anything results in an assertion failure:

Assertion failed: join_started(), file unifex/v2/async_scope.hpp, line 90

This can come up if the scope is a member of a class, and another member's constructor throws, e.g.:

class C {
  unifex::async_scope scope;
  TypeWhoseConstructorThrows m;
};

Is this the intended behavior?
It's understandable that one doesn't want to special-case the destructor's contract, but on the other hand it is quite odd not to be able to destroy a default-constructed object.

I'm not really sure if this can be easily worked around though without overhead for release builds. Maybe the scope could start in some kind of special state (say, std::size_t(-1)) and transition out of it in try_record_start(), but guarded by #ifndef NDEBUG?

@jesswong
Copy link
Contributor

jesswong commented Nov 5, 2024

Thanks for bringing this up Andrey! This is definitely a bug and not a feature. Our standards proposal for async_scope addresses this problem by keeping track of some state. This is probably an opportunity for us to implement this as well for unifex::v2::async_scope..

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

No branches or pull requests

2 participants