-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
Fix Issue 17231 and Improve std.concurrency.locate #5205
Conversation
|
std/concurrency.d
Outdated
| if (auto name = tid in namesByTid) | ||
| return *name; | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: replace the whole implementation with
synchronized (registryLock)
return namesByTid.get(tid, null);
std/concurrency.d
Outdated
| @@ -1076,6 +1076,24 @@ Tid locate( string name ) | |||
| } | |||
| } | |||
|
|
|||
| /** | |||
| * Gets all of the names associated with the $(LREF Tid). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest: Gets an array of all
std/concurrency.d
Outdated
| * tid = The $(LREF Tid) to locate within the registry. | ||
| * | ||
| * Returns: | ||
| * The associated name or `null` if `tid` is not registered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest: An array of the associated names
|
Would be nice to have a See Also section for the inverse and registering functions |
|
Also, unittests |
|
@John-Colvin Fixed |
std/concurrency.d
Outdated
| { | ||
| auto id = thisTid(); | ||
| assert(register("Main", id)); | ||
| assert(locate(id) == ["Main"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if another unittest (or static this) has registered anything for the main thread. If you think that matters, you could wrap the whole unittest in spawn so you know you'll have a new id.
|
@John-Colvin Fixed again. Also added example for the other overload |
c15445d to
c9260ac
Compare
|
Lgtm. If you want to do a real belt and braces job, check for what happens when there aren't any names registered, if an incorrect name is passed in, check that multiple names are all reported correctly etc. |
|
|
|
which is odd, because I developed this patch on macOS |
c9260ac to
4f481ab
Compare
|
I don't really have time to fix this right now, so closing |
Brought up in https://forum.dlang.org/post/zvhzxmqeponyhtphqbsb@forum.dlang.org