Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libutil/include/nix/util/thread-pool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public:
/**
* Enqueue a function to be executed by the thread pool.
*/
void enqueue(const work_t & t);
void enqueue(work_t t);

/**
* Execute work items until the queue is empty.
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/thread-pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void ThreadPool::shutdown()
thr.join();
}

void ThreadPool::enqueue(const work_t & t)
void ThreadPool::enqueue(work_t t)
{
auto state(state_.lock());
if (quit)
throw ThreadPoolShutDown("cannot enqueue a work item while the thread pool is shutting down");
state->pending.push(t);
state->pending.push(std::move(t));
/* Note: process() also executes items, so count it as a worker. */
if (state->pending.size() > state->workers.size() + 1 && state->workers.size() + 1 < maxThreads)
state->workers.emplace_back(&ThreadPool::doWork, this, false);
Expand Down
Loading