This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Implement CreateSemaphoreExA/W via CreateSemaphoreA/W#261
Merged
Conversation
Member
|
Thanks Steve. It looks like the dwFlags are reserved parameter and must be zero and the CreateSemaphoreExW is used only through the following macro: #define WszCreateSemaphore(_secattr, _count, _maxcount, _name) CreateSemaphoreExW((_secattr), (_count), (_maxcount), (_name), 0, SEMAPHORE_ALL_ACCESS)So the only value of the dwDesiredAccess is the SEMAPHORE_ALL_ACCESS. That means that your implementation is complete for the current usage. I'd recommend just asserting that the dwDesiredAccess is the SEMAPHORE_ALL_ACCESS. |
Any managed code that touches the ThreadPool is currently crashing when the ThreadPool tries to initialize. This is due to it creating a semaphore via CreateSemaphoreExA/W in the pal, and those functions not being implemented. This commit just implements those functions by delegating to their non-Ex counterparts. With this change, ThreadPool.QueueUserWorkItem, Task.Run, etc. are able to successfully schedule work and have it executed.
217f23f to
4bbce08
Compare
Member
Author
|
Thanks, Jan. I added the assert and updated the associated comment. |
Member
|
LGTM |
stephentoub
added a commit
that referenced
this pull request
Feb 13, 2015
Implement CreateSemaphoreExA/W via CreateSemaphoreA/W
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any managed code that touches the ThreadPool is currently crashing when the ThreadPool tries to initialize. This is due to it creating a semaphore via CreateSemaphoreEx in the pal, and those functions not being implemented.
To help make forward progress, this commit just implements those functions simply by delegating to their non-Ex counterparts, ignoring the additional arguments that come with the Ex versions. With this change, ThreadPool.QueueUserWorkItem, Task.Run, etc. are able to successfully schedule work and have it executed.
I've left the "TODO: Implement this!" comments in place, under the assumption that these implementations are shortish-term workarounds.