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

Abstraction on top of Win32 Named Events that can be set only once #242

Merged
merged 4 commits into from
Jul 26, 2022

Conversation

CarlosNihelton
Copy link
Collaborator

@CarlosNihelton CarlosNihelton commented Jul 25, 2022

Abstract

An abstraction on top of Win32 Named Events that can be set only once.

NOTE: Win32 Events (named or unnamed) are resetable, meaning that one can toggle on-off as much as desired. They
can even be automatically reset by the OS, if configured to do so by the CreateEvent function. This class
restricts that behavior by closing the OS handle and nulling out the private field that would represent it, thus
rendering the object useless after being once set.

Usage

Ensure a unique name is used for its initialization. This is an IPC mechanism, so other processes will find it.

SetOnceNamedEvent event(L"unique_identifyier");

When something interesting happens and you want to let the world know about it, set the event:

bool ok = event.set();

That's it. From now on the variable is useless. The event remains valid from a succesfull construction until
it's set.

ASSERT_FALSE(event.isValid())

That will be used to notify the OOBE of the distro registration completion as well as to kindly ask it to quit, events that by nature happens at most once.

@CarlosNihelton CarlosNihelton marked this pull request as ready for review July 25, 2022 15:09
Copy link
Collaborator

@EduardGomezEscandell EduardGomezEscandell left a comment

Choose a reason for hiding this comment

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

Not usually a purist of noexcepts, but this codebase is quite cool in that they are thoroughly used, so I'd try to keep it that way.

DistroLauncher/SetOnceNamedEvent.cpp Outdated Show resolved Hide resolved
DistroLauncher/SetOnceNamedEvent.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Please check out carefully the isses found by clang-tidy in the new code ⚠️
⚠️ clang-format found formatting issues in the code submitted.:warning:
Make sure to run clang-format and update this pull request.
(1/1)

DistroLauncher/SetOnceNamedEvent.cpp Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@CarlosNihelton
Copy link
Collaborator Author

The build workflow is failing due an issue in the flutter action. I'll push another PR to fix the action version temporarily until the upstream is fixed.

@CarlosNihelton CarlosNihelton merged commit 90e2d18 into main Jul 26, 2022
@CarlosNihelton CarlosNihelton deleted the named-event-deeng-289 branch July 26, 2022 11:04
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.

None yet

2 participants