Skip to content

Commit 32e3a6b

Browse files
committed
src: use env->RequestInterrupt() for inspector io thread start
This cleans up `Agent::RequestIoThreadStart()` significantly. PR-URL: #32523 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 583edd9 commit 32e3a6b

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/inspector_agent.cc

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ using v8::Message;
4747
using v8::Object;
4848
using v8::String;
4949
using v8::Task;
50-
using v8::TaskRunner;
5150
using v8::Value;
5251

5352
using v8_inspector::StringBuffer;
@@ -63,18 +62,6 @@ static std::atomic_bool start_io_thread_async_initialized { false };
6362
// Protects the Agent* stored in start_io_thread_async.data.
6463
static Mutex start_io_thread_async_mutex;
6564

66-
class StartIoTask : public Task {
67-
public:
68-
explicit StartIoTask(Agent* agent) : agent(agent) {}
69-
70-
void Run() override {
71-
agent->StartIoThread();
72-
}
73-
74-
private:
75-
Agent* agent;
76-
};
77-
7865
std::unique_ptr<StringBuffer> ToProtocolString(Isolate* isolate,
7966
Local<Value> value) {
8067
TwoByteValue buffer(isolate, value);
@@ -86,10 +73,6 @@ void StartIoThreadAsyncCallback(uv_async_t* handle) {
8673
static_cast<Agent*>(handle->data)->StartIoThread();
8774
}
8875

89-
void StartIoInterrupt(Isolate* isolate, void* agent) {
90-
static_cast<Agent*>(agent)->StartIoThread();
91-
}
92-
9376

9477
#ifdef __POSIX__
9578
static void StartIoThreadWakeup(int signo, siginfo_t* info, void* ucontext) {
@@ -978,12 +961,10 @@ void Agent::RequestIoThreadStart() {
978961
// for IO events)
979962
CHECK(start_io_thread_async_initialized);
980963
uv_async_send(&start_io_thread_async);
981-
Isolate* isolate = parent_env_->isolate();
982-
v8::Platform* platform = parent_env_->isolate_data()->platform();
983-
std::shared_ptr<TaskRunner> taskrunner =
984-
platform->GetForegroundTaskRunner(isolate);
985-
taskrunner->PostTask(std::make_unique<StartIoTask>(this));
986-
isolate->RequestInterrupt(StartIoInterrupt, this);
964+
parent_env_->RequestInterrupt([this](Environment*) {
965+
StartIoThread();
966+
});
967+
987968
CHECK(start_io_thread_async_initialized);
988969
uv_async_send(&start_io_thread_async);
989970
}

0 commit comments

Comments
 (0)