gul-cpp / gul14

General Utility Library for C++14
https://gul14.info/
GNU Lesser General Public License v2.1
2 stars 1 forks source link

ThreadPool::TaskHandle: Add default constructor #89

Closed alt-graph closed 6 months ago

alt-graph commented 6 months ago

Without a default constructor, it is almost impossible to store a TaskHandle in some user-defined data structure. This limits its usefulness dramatically. Hence, this PR adds a simple default constructor and a test to check that the default-constructed task handle does what one would expect (namely, nothing useful).

Finii commented 6 months ago

Maybe we want to change this to the number one then, to try to avoid referencing something that is not correct?

image

alt-graph commented 6 months ago

Maybe we want to change this to the number one then, to try to avoid referencing something that is not correct?

There is no possibility of referencing something that is not correct because we have no pointer to a ThreadPool at all, hence we cannot ask it about the wrong ID. Without a ThreadPool, the integer ID is meaningless.

Finii commented 6 months ago

Yes I just noticed that after setting up a test that calls TaskHandle{}.cancel();

Merge away ;)