Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-07-15 23:17:45 +0300
committerAnna Henningsen <anna@addaleax.net>2019-08-01 01:51:43 +0300
commit5207dec0175de92116262e8382d6ac57def3a203 (patch)
treee90e855f7a8a228e00fe0d49fb311b319de74c3d /src/cares_wrap.cc
parent61f3a5c60ad78506e9e0caae061a04ccab878ca1 (diff)
src: allow generic C++ callables in SetImmediate()
Modify the native `SetImmediate()` functions to take generic C++ callables as arguments. This makes passing arguments to the callback easier, and in particular, it allows passing `std::unique_ptr`s directly, which in turn makes sure that the data they point to is deleted if the `Environment` is torn down before the callback can run. PR-URL: https://github.com/nodejs/node/pull/28704 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r--src/cares_wrap.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index 85d0fdbde64..96062cb4819 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -690,9 +690,9 @@ class QueryWrap : public AsyncWrap {
}
void QueueResponseCallback(int status) {
- env()->SetImmediate([](Environment*, void* data) {
- static_cast<QueryWrap*>(data)->AfterResponse();
- }, this, object());
+ env()->SetImmediate([this](Environment*) {
+ AfterResponse();
+ }, object());
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
channel_->ModifyActivityQueryCount(-1);