Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
[squash] address Timothy’s nits
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Oct 7, 2017
1 parent 995afd6 commit f9b3f31
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ inline uint32_t* IsolateData::zero_fill_field() const {
return zero_fill_field_;
}

inline WorkerSupportingPlatform* IsolateData::platform() const {
inline MultiIsolatePlatform* IsolateData::platform() const {
return platform_;
}

Expand Down
2 changes: 1 addition & 1 deletion src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using v8::String;

IsolateData::IsolateData(Isolate* isolate,
uv_loop_t* event_loop,
WorkerSupportingPlatform* platform,
MultiIsolatePlatform* platform,
uint32_t* zero_fill_field) :

// Create string and private symbol properties as internalized one byte strings.
Expand Down
6 changes: 3 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ struct node_async_ids {
class IsolateData {
public:
IsolateData(v8::Isolate* isolate, uv_loop_t* event_loop,
WorkerSupportingPlatform* platform = nullptr,
MultiIsolatePlatform* platform = nullptr,
uint32_t* zero_fill_field = nullptr);
~IsolateData();
inline uv_loop_t* event_loop() const;
inline uint32_t* zero_fill_field() const;
inline WorkerSupportingPlatform* platform() const;
inline MultiIsolatePlatform* platform() const;

#define VP(PropertyName, StringValue) V(v8::Private, PropertyName)
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
Expand Down Expand Up @@ -373,7 +373,7 @@ class IsolateData {
v8::Isolate* const isolate_;
uv_loop_t* const event_loop_;
uint32_t* const zero_fill_field_;
WorkerSupportingPlatform* platform_;
MultiIsolatePlatform* platform_;

DISALLOW_COPY_AND_ASSIGN(IsolateData);
};
Expand Down
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4686,7 +4686,7 @@ IsolateData* CreateIsolateData(Isolate* isolate, uv_loop_t* loop) {
IsolateData* CreateIsolateData(
Isolate* isolate,
uv_loop_t* loop,
WorkerSupportingPlatform* platform) {
MultiIsolatePlatform* platform) {
return new IsolateData(isolate, loop, platform);
}

Expand Down
11 changes: 6 additions & 5 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ NODE_EXTERN void Init(int* argc,
class IsolateData;
class Environment;

class WorkerSupportingPlatform : public v8::Platform {
class MultiIsolatePlatform : public v8::Platform {
public:
virtual ~WorkerSupportingPlatform() { }
virtual ~MultiIsolatePlatform() { }
virtual void DrainBackgroundTasks(v8::Isolate* isolate) = 0;

// These will be called by the `IsolateData` creation/destruction functions.
Expand All @@ -221,15 +221,16 @@ class WorkerSupportingPlatform : public v8::Platform {
virtual void UnregisterIsolate(IsolateData* isolate_data) = 0;
};

// If `platform` is passed, it will be used to register new worker instances.
// It can be `nullptr`, in which case creating new workers will not work.
// If `platform` is passed, it will be used to register new Worker instances.
// It can be `nullptr`, in which case creating new Workers inside of
// Environments that use this `IsolateData` will not work.
NODE_EXTERN IsolateData* CreateIsolateData(
v8::Isolate* isolate,
struct uv_loop_s* loop);
NODE_EXTERN IsolateData* CreateIsolateData(
v8::Isolate* isolate,
struct uv_loop_s* loop,
WorkerSupportingPlatform* platform);
MultiIsolatePlatform* platform);
NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data);

NODE_EXTERN Environment* CreateEnvironment(IsolateData* isolate_data,
Expand Down
10 changes: 5 additions & 5 deletions src/node_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ using v8::Platform;
using v8::Task;
using v8::TracingController;

void PerIsolatePlatformData::FlushTasks(uv_async_t* handle) {
auto platform_data = static_cast<PerIsolatePlatformData*>(handle->data);
platform_data->FlushForegroundTasksInternal();
}

static void BackgroundRunner(void* data) {
TaskQueue<Task>* background_tasks = static_cast<TaskQueue<Task>*>(data);
while (Task* task = background_tasks->BlockingPop()) {
Expand All @@ -38,6 +33,11 @@ PerIsolatePlatformData::PerIsolatePlatformData(
uv_unref(reinterpret_cast<uv_handle_t*>(flush_tasks_));
}

void PerIsolatePlatformData::FlushTasks(uv_async_t* handle) {
auto platform_data = static_cast<PerIsolatePlatformData*>(handle->data);
platform_data->FlushForegroundTasksInternal();
}

void PerIsolatePlatformData::CallOnForegroundThread(Task* task) {
foreground_tasks_.Push(task);
uv_async_send(flush_tasks_);
Expand Down
4 changes: 2 additions & 2 deletions src/node_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define SRC_NODE_PLATFORM_H_

#include <queue>
#include <vector>
#include <unordered_map>
#include <vector>

#include "libplatform/libplatform.h"
#include "node.h"
Expand Down Expand Up @@ -63,7 +63,7 @@ class PerIsolatePlatformData {
TaskQueue<std::pair<v8::Task*, double>> foreground_delayed_tasks_;
};

class NodePlatform : public WorkerSupportingPlatform {
class NodePlatform : public MultiIsolatePlatform {
public:
NodePlatform(int thread_pool_size, v8::TracingController* tracing_controller);
virtual ~NodePlatform() {}
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/node_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class NodeTestFixture : public ::testing::Test {
public:
static uv_loop_t* CurrentLoop() { return &current_loop; }

node::WorkerSupportingPlatform* Platform() const { return platform_; }
node::MultiIsolatePlatform* Platform() const { return platform_; }

protected:
v8::Isolate::CreateParams params_;
Expand Down

0 comments on commit f9b3f31

Please sign in to comment.