Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3bd9fc0
PTP: Use uv_executor_queue_work and add options for zlib, crypto
davisjam Aug 31, 2018
bc0f42e
PTP: First pass at node::threadpool
davisjam Sep 3, 2018
7200111
pTP: rewire NodePlatform to use Threadpool
davisjam Sep 6, 2018
662825f
PTP: Refactor out a LibuvExecutor
davisjam Sep 6, 2018
a894655
PTP: linting
davisjam Sep 6, 2018
8771ad8
PTP: Add state tracking for Tasks
davisjam Sep 6, 2018
3a2bbb6
PTP: Bugfix: start and stop DelayedTaskScheduler
davisjam Sep 6, 2018
8f6df02
PTP: BlockingDrain for Threadpool and TaskQueue
davisjam Sep 6, 2018
5892ef7
PTP: CreatePlatform creates its own TP
davisjam Sep 7, 2018
95bdaad
PTP: linting, comments, etc.
davisjam Sep 7, 2018
76ca768
PTP: More unit tests
davisjam Sep 7, 2018
83e91b4
PTP: Threadpool RAII; UV_THREADPOOL_SIZE
davisjam Sep 7, 2018
a654044
PTP: Cancel Tasks Post'ed to the Threadpool
davisjam Sep 7, 2018
706f2c6
PTP: Add WorkerGroup class to manage Workers
davisjam Sep 9, 2018
d79920f
PTP: Expose NodeThreadpool as public TP face
davisjam Sep 9, 2018
223cfc4
PTP: Subclass NodeThreadpool for CPU/IO split
davisjam Sep 9, 2018
f462078
PTP: Generalize subclass type
davisjam Sep 9, 2018
153dcdb
PTP: ByTaskOriginPartitonedNodeThreadpool
davisjam Sep 9, 2018
8cf91cd
PTP: ByTaskOriginAndTypePartitonedNodeThreadpool
davisjam Sep 10, 2018
21a931a
PTP: Track Task queue and run times
davisjam Sep 10, 2018
076ccca
PTP: Refactor to DRY in PartitionedNodeThreadpool
davisjam Sep 11, 2018
ec5e624
PTP: Profiling: Sample TaskQueue lengths
davisjam Sep 11, 2018
2547f52
PTP: Add UnpartitionedPartitionedNodeThreadpool
davisjam Sep 11, 2018
61b4cd3
PTP: Visualize threadpool behavior
davisjam Sep 11, 2018
0c40738
PTP: change env vars for consistency
davisjam Sep 16, 2018
003c147
PTP: dump stats in either [Signal]Exit or Start
davisjam Sep 16, 2018
c289dcd
PTP: PrintStats tweaks for easy parsing
davisjam Sep 17, 2018
c98c8d6
PTP: address changes in the libuv PR
davisjam Sep 30, 2018
64ce6e1
REMOVE ME: PTP: include libuv changes so people can try prototype
davisjam Sep 30, 2018
883d7fc
PTP: make linter happy
davisjam Sep 30, 2018
83e4214
REMOVE ME: PTP: include libuv changes so people can try prototype
davisjam Sep 30, 2018
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
Prev Previous commit
Next Next commit
PTP: Add state tracking for Tasks
Tasks can be in one of these states:
  - QUEUED
  - ASSIGNED
  - COMPLETED
  • Loading branch information
davisjam committed Sep 6, 2018
commit 8771ad864ef209c1e388dda335e7f652e492570c
12 changes: 12 additions & 0 deletions src/node_threadpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ void Worker::Join(void) {
void Worker::_Run(void* data) {
TaskQueue* queue = static_cast<TaskQueue*>(data);
while (std::unique_ptr<Task> task = queue->BlockingPop()) {
task->UpdateState(Task::ASSIGNED);
task->Run();
task->UpdateState(Task::COMPLETED);
}
}

/**************
* Task
***************/

void Task::UpdateState(enum State state) {
state_ = state;
}

/**************
* LibuvExecutor
***************/
Expand Down Expand Up @@ -139,8 +149,10 @@ bool TaskQueue::Push(std::unique_ptr<Task> task) {
return false;
}

task->UpdateState(Task::QUEUED);
queue_.push(std::move(task));
tasks_available_.Signal(scoped_lock);

return true;
}

Expand Down
13 changes: 12 additions & 1 deletion src/node_threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,28 @@ class TaskDetails {
// - User work from the N-API
class Task {
public:
enum State {
QUEUED
, ASSIGNED
, COMPLETED
};

Task() {}
// Invoked after Run().
virtual ~Task() {}

// Invoked on some thread in the Threadpool.
virtual void Run() = 0;

// Different Threadpool components should update this as the Task travels around.
void UpdateState(enum State state);

// Run() can access details.
// Should be set in subclass constructor.
TaskDetails details_;
private:

protected:
enum State state_;
};

// Shim that we plug into the libuv "pluggable TP" interface.
Expand Down