Change the worker to store the job using shared_ptr, so caller can still hold a reference to the job for other purpose

This commit is contained in:
Noisyfox
2025-09-29 23:15:15 +08:00
parent ddee9f3976
commit 8611125008
4 changed files with 10 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ class BoostThreadWorker : public Worker, private Job::Ctl
{
struct JobEntry // Goes into worker and also out of worker as a finalize msg
{
std::unique_ptr<Job> job;
std::shared_ptr<Job> job;
bool canceled = false;
std::exception_ptr eptr = nullptr;
};
@@ -110,7 +110,7 @@ public:
BoostThreadWorker &operator=(const BoostThreadWorker &) = delete;
BoostThreadWorker &operator=(BoostThreadWorker &&) = delete;
bool push(std::unique_ptr<Job> job) override;
bool push(std::shared_ptr<Job> job) override;
bool is_idle() const override
{