Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eccbec9

Browse filesBrowse files
trevnorrisrvagg
authored andcommitted
async_wrap: new instances get uid
New instances of AsyncWrap are automatically assigned a unique id. The value will be used in future commits to communicate additional information via the async hooks. While the largest value we can reliably communicate to JS is 2^53, even if a new AsyncWrap is created every 100ns the uid won't reach its end for 28.5 years. PR-URL: #3461 Reviewed-By: Fedor Indutny <fedor@indutny.com>
1 parent 5d34c81 commit eccbec9
Copy full SHA for eccbec9

File tree

Expand file treeCollapse file tree

4 files changed

+18
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+18
-1
lines changed
Open diff view settings
Collapse file

‎src/async-wrap-inl.h‎

Copy file name to clipboardExpand all lines: src/async-wrap-inl.h
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ inline AsyncWrap::AsyncWrap(Environment* env,
1717
v8::Local<v8::Object> object,
1818
ProviderType provider,
1919
AsyncWrap* parent)
20-
: BaseObject(env, object), bits_(static_cast<uint32_t>(provider) << 1) {
20+
: BaseObject(env, object), bits_(static_cast<uint32_t>(provider) << 1),
21+
uid_(env->get_async_wrap_uid()) {
2122
CHECK_NE(provider, PROVIDER_NONE);
2223
CHECK_GE(object->InternalFieldCount(), 1);
2324

@@ -66,6 +67,11 @@ inline AsyncWrap::ProviderType AsyncWrap::provider_type() const {
6667
}
6768

6869

70+
inline int64_t AsyncWrap::get_uid() const {
71+
return uid_;
72+
}
73+
74+
6975
inline v8::Local<v8::Value> AsyncWrap::MakeCallback(
7076
const v8::Local<v8::String> symbol,
7177
int argc,
Collapse file

‎src/async-wrap.h‎

Copy file name to clipboardExpand all lines: src/async-wrap.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class AsyncWrap : public BaseObject {
5555

5656
inline ProviderType provider_type() const;
5757

58+
inline int64_t get_uid() const;
59+
5860
// Only call these within a valid HandleScope.
5961
v8::Local<v8::Value> MakeCallback(const v8::Local<v8::Function> cb,
6062
int argc,
@@ -76,6 +78,7 @@ class AsyncWrap : public BaseObject {
7678
// expected the context object will receive a _asyncQueue object property
7779
// that will be used to call pre/post in MakeCallback.
7880
uint32_t bits_;
81+
const int64_t uid_;
7982
};
8083

8184
void LoadAsyncWrapperInfo(Environment* env);
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ inline Environment::Environment(v8::Local<v8::Context> context,
210210
using_domains_(false),
211211
printed_error_(false),
212212
trace_sync_io_(false),
213+
async_wrap_uid_(0),
213214
debugger_agent_(this),
214215
http_parser_buffer_(nullptr),
215216
context_(context->GetIsolate(), context) {
@@ -359,6 +360,10 @@ inline void Environment::set_trace_sync_io(bool value) {
359360
trace_sync_io_ = value;
360361
}
361362

363+
inline int64_t Environment::get_async_wrap_uid() {
364+
return ++async_wrap_uid_;
365+
}
366+
362367
inline uint32_t* Environment::heap_statistics_buffer() const {
363368
CHECK_NE(heap_statistics_buffer_, nullptr);
364369
return heap_statistics_buffer_;
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ class Environment {
446446
void PrintSyncTrace() const;
447447
inline void set_trace_sync_io(bool value);
448448

449+
inline int64_t get_async_wrap_uid();
450+
449451
bool KickNextTick();
450452

451453
inline uint32_t* heap_statistics_buffer() const;
@@ -541,6 +543,7 @@ class Environment {
541543
bool using_domains_;
542544
bool printed_error_;
543545
bool trace_sync_io_;
546+
int64_t async_wrap_uid_;
544547
debugger::Agent debugger_agent_;
545548

546549
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.