IHTAThreading - `IIHTAThread::GetPriority` returns the wrong priority when internal thread is not initiated
Summary
The unit test "Thread Interface - Priority" fails with
Randomness seeded to: 2033983552
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------------------------------------------------------
Thread Interface
Priority
-------------------------------------------------------------------------------
D:\Users\palenda\Documents\coding\ihtautilitylibs\IHTAThreading\test\ihta_threading_unit_test_thread_interface.cpp(11)
...............................................................................
D:\Users\palenda\Documents\coding\ihtautilitylibs\IHTAThreading\test\ihta_threading_unit_test_thread_interface.cpp(19): FAILED:
REQUIRE( thread.GetPriority( ) == currentPriority )
with expansion:
1 == 0
===============================================================================
test cases: 2 | 1 passed | 1 failed
assertions: 13 | 12 passed | 1 failed
Steps to reproduce
Run the unit test application.
What is the current bug behavior?
The test case fails.
What is the expected correct behavior?
The test runs successfully.
Relevant logs and/or screenshots
See above.
Reason and possible fixes
The reason for this is, that IIHTAThread
alone does not initialize the internal thread.
As a result, the native get priority method does not return a valid priority.
In case of windows, GetThreadPriority
returns THREAD_PRIORITY_ERROR_RETURN
which is equal to 2147483647 (LONG_MAX) see here, here and here.
It has to be determined if this is undefined behaviour and, if this is not the case, how this should be handled.
In theory the IIHTAThread
interface should never be constructed on its own.
However, a derivation of it may not create a valid thread.