9
9
#include " async_wrap.h"
10
10
#include " async_wrap-inl.h"
11
11
12
+ #include < string>
13
+
12
14
using v8::ArrayBuffer;
13
15
using v8::Context;
14
16
using v8::Function;
@@ -30,7 +32,7 @@ namespace worker {
30
32
31
33
namespace {
32
34
33
- double next_thread_id = 1 ;
35
+ uint64_t next_thread_id = 1 ;
34
36
Mutex next_thread_id_mutex;
35
37
36
38
} // anonymous namespace
@@ -44,7 +46,8 @@ Worker::Worker(Environment* env, Local<Object> wrap)
44
46
}
45
47
wrap->Set (env->context (),
46
48
env->thread_id_string (),
47
- Number::New (env->isolate (), thread_id_)).FromJust ();
49
+ Number::New (env->isolate (),
50
+ static_cast <double >(thread_id_))).FromJust ();
48
51
49
52
// Set up everything that needs to be set up in the parent environment.
50
53
parent_port_ = MessagePort::New (env, env->context ());
@@ -112,6 +115,11 @@ bool Worker::is_stopped() const {
112
115
}
113
116
114
117
void Worker::Run () {
118
+ std::string name = " WorkerThread " ;
119
+ name += std::to_string (thread_id_);
120
+ TRACE_EVENT_METADATA1 (
121
+ " __metadata" , " thread_name" , " name" ,
122
+ TRACE_STR_COPY (name.c_str ()));
115
123
MultiIsolatePlatform* platform = isolate_data_->platform ();
116
124
CHECK_NE (platform, nullptr );
117
125
@@ -418,7 +426,8 @@ void InitWorker(Local<Object> target,
418
426
auto thread_id_string = FIXED_ONE_BYTE_STRING (env->isolate (), " threadId" );
419
427
target->Set (env->context (),
420
428
thread_id_string,
421
- Number::New (env->isolate (), env->thread_id ())).FromJust ();
429
+ Number::New (env->isolate (),
430
+ static_cast <double >(env->thread_id ()))).FromJust ();
422
431
}
423
432
424
433
} // anonymous namespace
0 commit comments