-
Notifications
You must be signed in to change notification settings - Fork 506
Thread priorities on Unix #8332
Description
As a game developer I like to have some control over the thread priorities.
I checked the code and it's not implemented, yet. Is there a reason beside nobody had the time yet?
Based on the code there are two missing parts
- Getting a handle back to the managed part during thread creation.
- Add native functions to get and set the priority
Beside of converting the priorities the actual set and get functions should be pretty easy. The question here is only if the conversion should be done on the C# or C side?
The handle might be more tricky as pthread_t doesn't need to be a numeric type.
Therefore my idea is to store the handle in the managed part a a intptr. For systems that uses a numeric type for pthread_t that is smaller than a pointer we can just use it direct. On other systems we need to allocate some memory to store a copy of pthread_t and the managed part will store a pointer to this memory. But we need to make sure the memory is freed when the managed thread object is collected.
The other option would be doing it in the same way as socket addresses are store. The managed part asks the native how much space is needed. It creates a byte array and every time a native call is made the array is pinned. While this is very straight forward it might be less efficent. But I don't expect that many calls there.