blob: 4f470e63daa5545a4cfb5429b765fb0d95c24e75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#ifndef REQ_WRAP_H_
#define REQ_WRAP_H_
namespace node {
template <typename T>
class ReqWrap {
public:
ReqWrap() {
v8::HandleScope scope;
object_ = v8::Persistent<v8::Object>::New(v8::Object::New());
}
~ReqWrap() {
// Assert that someone has called Dispatched()
assert(req_.data == this);
assert(!object_.IsEmpty());
object_.Dispose();
object_.Clear();
}
// Call this after the req has been dispatched.
void Dispatched() {
req_.data = this;
}
v8::Persistent<v8::Object> object_;
T req_;
void* data_;
};
} // namespace node
#endif // REQ_WRAP_H_
|