diff options
author | Franziska Hinkelmann <franziska.hinkelmann@gmail.com> | 2017-11-12 18:23:31 +0300 |
---|---|---|
committer | Franziska Hinkelmann <franziska.hinkelmann@gmail.com> | 2017-11-14 10:27:33 +0300 |
commit | 81010421c54770f2c604ec29d192a3d2c2406ae0 (patch) | |
tree | d8b396a56103654f7df3ac2d2997592302ab7bbf /src/node_platform.h | |
parent | 8680bb9f1a0163cfbdc4443c1eb2b56c5e443616 (diff) |
src: use unique_ptr in platform implementation
Replace raw pointers in task queues with std::unique_ptr. This
makes ownership obvious.
PR-URL: https://github.com/nodejs/node/pull/16970
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_platform.h')
-rw-r--r-- | src/node_platform.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/node_platform.h b/src/node_platform.h index 73c2509e1a0..584506ae1f1 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -22,9 +22,9 @@ class TaskQueue { TaskQueue(); ~TaskQueue() {} - void Push(T* task); - T* Pop(); - T* BlockingPop(); + void Push(std::unique_ptr<T> task); + std::unique_ptr<T> Pop(); + std::unique_ptr<T> BlockingPop(); void NotifyOfCompletion(); void BlockingDrain(); void Stop(); @@ -35,11 +35,11 @@ class TaskQueue { ConditionVariable tasks_drained_; int outstanding_tasks_; bool stopped_; - std::queue<T*> task_queue_; + std::queue<std::unique_ptr<T>> task_queue_; }; struct DelayedTask { - v8::Task* task; + std::unique_ptr<v8::Task> task; uv_timer_t timer; double timeout; PerIsolatePlatformData* platform_data; @@ -50,8 +50,9 @@ class PerIsolatePlatformData { PerIsolatePlatformData(v8::Isolate* isolate, uv_loop_t* loop); ~PerIsolatePlatformData(); - void CallOnForegroundThread(v8::Task* task); - void CallDelayedOnForegroundThread(v8::Task* task, double delay_in_seconds); + void CallOnForegroundThread(std::unique_ptr<v8::Task> task); + void CallDelayedOnForegroundThread(std::unique_ptr<v8::Task> task, + double delay_in_seconds); void Shutdown(); @@ -64,7 +65,7 @@ class PerIsolatePlatformData { private: static void FlushTasks(uv_async_t* handle); - static void RunForegroundTask(v8::Task* task); + static void RunForegroundTask(std::unique_ptr<v8::Task> task); static void RunForegroundTask(uv_timer_t* timer); int ref_count_ = 1; |