add core.sync.event to be used as Windows events#2517
add core.sync.event to be used as Windows events#2517dlang-bot merged 3 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @rainers! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2517" |
3f7ef75 to
0232a3f
Compare
|
|
||
| version (Windows) | ||
| { | ||
| import core.sys.windows.basetsd /+: HANDLE +/; |
There was a problem hiding this comment.
Why these comments?
There was a problem hiding this comment.
This follows the example of https://github.com/dlang/druntime/pull/2400/files (selective imports create a public alias).
There was a problem hiding this comment.
Hasn't this been fixed a year ago or so?
There was a problem hiding this comment.
Oh well, looks like it's really still in deprecation, but there's a PR to remove them for good:
There was a problem hiding this comment.
That will go in very soon.
There was a problem hiding this comment.
Not good enough:
test.d(3): Deprecation: core.sync.event.HANDLE is not visible from module test
src/core/sync/event.d
Outdated
| pthread_cond_signal(&waiter.cond); | ||
| pthread_mutex_unlock(&waiter.mutex); | ||
| } | ||
| pthread_mutex_unlock(&m_mutex); |
There was a problem hiding this comment.
The function is nothrow anyway, so it doesn't make a difference in code generation. With a short function like this, having the symmetry show up in the function is slightly better IMO.
| * manualReset = the state of the event is not reset automatically after resuming waiting clients | ||
| * initialState = initial state of the signal | ||
| */ | ||
| void initialize(bool manualReset, bool initialState) |
There was a problem hiding this comment.
Why is this a separate method?
There was a problem hiding this comment.
You cannot pass arguments to the constructor if it is part of another struct, e.g. https://github.com/dlang/druntime/pull/2514/files#diff-6615611ba51118215a271e3500c61122R2605. You have to use an explicit initialize-call then. __ctor could be an alternative, but I think it should not be part of the API.
There was a problem hiding this comment.
Is there a downside to do evStart = Event(...) in Gcx.initialize?
There was a problem hiding this comment.
I've explicitly added @disable this(this) as this could duplicate the handle reference.
There was a problem hiding this comment.
Does not seem to prevent assignment: https://run.dlang.io/is/iefkBG.
There was a problem hiding this comment.
Hmm, seems like opAssign should be disabled, too.
There was a problem hiding this comment.
If that's required then I'm fine with using initialize instead of a constructor.
e0006b2 to
0fb8576
Compare
| terminate(); | ||
| } | ||
|
|
||
| void terminate() |
|
No changelog. |
thewilsonator
left a comment
There was a problem hiding this comment.
Pending:
- uncommented selective imports
- changelog
initializein place of constructorterminatedocumentation
0fb8576 to
018e340
Compare
|
Added changelog and a bit more documentation. I've also added a bool to keep track of the initialization state of the posix version.
I think this should be done for all the imports once the dmd deprecation is gone (dlang/dmd#9393 doesn't help for this case yet). |
018e340 to
7bc28a8
Compare
|
|
7171e27 to
05e84ca
Compare
05e84ca to
46987a8
Compare
|
Rainer, have you explored whether pthread_cond_broadcast and a single condition variable could work too? |
Didn't know about it, now replaced the manual implementation. |
0099e2a to
a5d9df2
Compare
| } | ||
| } | ||
|
|
||
| // Test single-thread (non-shared) use. |
There was a problem hiding this comment.
Maybe make this example public, s.t. there's at least one user-facing example.
There was a problem hiding this comment.
I think this example is a pretty bad one as it doesn't involve multiple threads. Maybe better to move the example from the changelog into the documentation?
There was a problem hiding this comment.
Sure. I just saw that the module is currently without any public example.
a5d9df2 to
ba5bbeb
Compare
| event.terminate(); | ||
| } | ||
| } | ||
| --- |
There was a problem hiding this comment.
Why isn't it a documented unittest instead ?
There was a problem hiding this comment.
I think its already a bit too long for a really good example, and making it actually runnable would make it even longer.
extracted from #2514