-
Notifications
You must be signed in to change notification settings - Fork 2.6k
WIP: Merge System.Threading.Thread into Internal.Runtime.Augments.RuntimeThread. #22032
Conversation
8dedeb8
to
693da9d
Compare
…ng to a Thread type in current namespace.
d7c062e
to
e433d8b
Compare
cc @marek-safar |
@@ -14,22 +14,135 @@ namespace Internal.Runtime.Augments | |||
{ | |||
public class RuntimeThread : CriticalFinalizerObject | |||
{ | |||
/*========================================================================= |
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.
Hmm, there is more code duplicating with CoreFX Thread that I expected
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.
Do you have anything specific you have in mind?
Let's wait for the Environment CoreFX->CoreCLR move to finish first, and then decide which option to take for this one. |
Sure. This is low-priority one, but I decided to tackle it because it bit me couple of times that the class name resolution didn't work as I expected (ie. |
Any new thoughts about this? |
@jkotas @stephentoub could you please advice Filip on future steps |
I think we should bring the public If we go with this plan, the first step should be to identify all files in CoreFX that need to be moved to CoreLib and move them to CoreLib shared partition in the CoreFX repo. (Except Thread.cs itself since it will require refactoring to integrate back to CoreLib.) |
In theory, yes. It'd be good to see the full transitive list before pulling the trigger. From a quick skim, it looks like the worst of it would be some permissions stuff via AppDomain, which should probably be in Corelib, anyway. |
This makes sense, all VM specific types are in CoreLib and this will hopefully make few dependencies simpler as well. I didn't check Thread dependencies chain but it's hopefully not too bad. |
Here's the list:
|
I tried copying the above files into CoreRT's System.Private.CoreLib to see if it can compile. I've got to the point where only resource strings are missing, so the list above should be fairly complete. |
Thanks for the list.
Is this actually exposed through API, or could the implementation just use |
Unfortunately it is exposed by |
|
I'm going to close this PR, but feel free to continue discussion. Is anyone planning to work on it? I'm notoriously bad at multi-repository code transfers, but if you are willing to bear with me I can try to reproduce the same PR sequence as for the |
We will be glad if you can help. |
And if you need help and get stuck, please let me know; I'll be happy to. |
Alright. I will get to work later today. |
This is just a proof of concept. It will likely break VS Debugger in its current shape, but it depends on how the VS Debugger accesses the
_managedThreadId
field.Here's a background on what I am trying to solve. It was already discussed in mono/mono#12470 (comment), but I will restate it here for clarity.
Right now CoreFX implements
System.Threading.Thread
using calls toInternal.Runtime.Augments.RuntimeThread
in CoreLib. The CoreRT implementation is quite clean, but for historical reasons the CoreCLR implementation is not. It's split intoRuntimeThread
and another internalSystem.Threading.Thread
type in CoreLib. This is an unfortunate situation where twoSystem.Threading.Thread
types exist, with different, but overlapping, functionality, in two different assemblies. To add insult to the injury some types in CoreLib reference theSystem.Threading.Thread
directly instead ofRuntimeThread
, which makes code sharing with CoreRT/Mono difficult.There are three proposed solutions for a cleanup:
Get rid of
System.Threading.Thread
in CoreLib and fold its functionality intoRuntimeThread
. This is implemented by this PR. Additionally,RuntimeThread
namespace should be changed to Internal.Threading.RuntimeThread to make it match the convention used for most types like that (not done in this PR and will require changes to CoreRT and CoreFX too).Keep
System.Threading.Thread
in CoreLib, but ensure that it is called only fromRuntimeThread
and unmanaged code. All other code would referenceRuntimeThread
only.Move
System.Threading.Thread
from CoreFX back to CoreLib, including its transitive dependency closure and get rid ofRuntimeThread
.Option 2) seems to be least favorable. The only thing going for it is that it won't break VS debugger and it's very limited in scope to the CoreCLR repository. Ultimately it doesn't solve the problem with two classes with the same name though.
Option 3) will require most shuffling of code between repositories.