Job class is unnecessarily hard to access #1654
-
|
I've finally written the code to use our existing job system for Jolt, but ran into a couple of unnecessary roadblocks. The Job class is defined inside JobSystem. It is also in a protected area. That means only a class that derives from JobSystem is able to create a custom Job class (to derive from it). It also means that storing pointers to JobSystem::Job in any other piece of code is difficult, because the declaration is inaccessible. I have a custom Task class. This had to somehow reference a Jolt Job. So now it holds a void* to a Job. But then it also can't call "Execute" and "Release" on the Job. Therefore I have to forward this to a (static) function on my custom JobSystem implementation, which then just casts the It would be much easier, if the Job class was not a (protected) class inside JobSystem, but simply a free-standing class. Additionally, functions like |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
This was actually on purpose because nobody should be using the
Looking through your change: Wouldn't a simple solution be to make
I am not sure if your solution is safe. Inside |
Beta Was this translation helpful? Give feedback.
-
I can give that a try. I'm generally not a fan of declaring classes inside classes, because that makes it impossible in C++ to forward declare types. Though even if I can work around it this way, it may still be an issue for other people with yet different use cases.
Hmm, I guess that's possible, but that wasn't obvious to me, seeing that the JobSystem interface takes Job pointers, not handles.
Haha, yes, you are correct. I already have a fix on a branch because I've run into that race condition a little after I completed the PR. |
Beta Was this translation helpful? Give feedback.
-
All of the interfaces that takes a |
Beta Was this translation helpful? Give feedback.
This was actually on purpose because nobody should be using the
Jobclass besides theJobSystemand its inherited classes. All other classes should be usingJobHandleinstead.