Permalink
Browse files

Abstract StreamWrap from TCPWrap

  • Loading branch information...
1 parent 404a4db commit 1ae148909a2bd220cf48218a4c9ff295a611a65e @ry ry committed Jul 18, 2011
Showing with 458 additions and 327 deletions.
  1. +35 −0 src/req_wrap.h
  2. +367 −0 src/stream_wrap.cc
  3. +42 −0 src/stream_wrap.h
  4. +13 −327 src/tcp_wrap.cc
  5. +1 −0 wscript
View
@@ -0,0 +1,35 @@
+#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_;
+};
+
+
+} // namespace node
+
+
+#endif // REQ_WRAP_H_
Oops, something went wrong.

0 comments on commit 1ae1489

Please sign in to comment.