Node.js  v8.x
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine
req-wrap-inl.h
Go to the documentation of this file.
1 #ifndef SRC_REQ_WRAP_INL_H_
2 #define SRC_REQ_WRAP_INL_H_
3 
4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5 
6 #include "req-wrap.h"
7 #include "async-wrap.h"
8 #include "async-wrap-inl.h"
9 #include "env.h"
10 #include "env-inl.h"
11 #include "util.h"
12 #include "util-inl.h"
13 
14 namespace node {
15 
16 template <typename T>
17 ReqWrap<T>::ReqWrap(Environment* env,
18  v8::Local<v8::Object> object,
19  AsyncWrap::ProviderType provider)
20  : AsyncWrap(env, object, provider) {
21  if (env->in_domain())
22  object->Set(env->domain_string(), env->domain_array()->Get(0));
23 
24  // FIXME(bnoordhuis) The fact that a reinterpret_cast is needed is
25  // arguably a good indicator that there should be more than one queue.
26  env->req_wrap_queue()->PushBack(reinterpret_cast<ReqWrap<uv_req_t>*>(this));
27 }
28 
29 template <typename T>
30 ReqWrap<T>::~ReqWrap() {
31  CHECK_EQ(req_.data, this); // Assert that someone has called Dispatched().
32  CHECK_EQ(false, persistent().IsEmpty());
33  persistent().Reset();
34 }
35 
36 template <typename T>
37 void ReqWrap<T>::Dispatched() {
38  req_.data = this;
39 }
40 
41 } // namespace node
42 
43 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
44 
45 #endif // SRC_REQ_WRAP_INL_H_