Skip to content
Newer
Older
100644 52 lines (40 sloc) 1.37 KB
0c7bf81 @ry Abstract out HandleWrap class
ry authored
1 #ifndef HANDLE_WRAP_H_
2 #define HANDLE_WRAP_H_
3
4 namespace node {
5
85404c5 @ry Move HandleWrap rules to one place
ry authored
6 // Rules:
7 //
8 // - Do not throw from handle methods. Set errno.
9 //
10 // - MakeCallback may only be made directly off the event loop.
11 // That is there can be no JavaScript stack frames underneith it.
12 // (Is there anyway to assert that?)
13 //
14 // - No use of v8::WeakReferenceCallback. The close callback signifies that
15 // we're done with a handle - external resources can be freed.
16 //
17 // - Reusable?
18 //
19 // - The uv_close_cb is used to free the c++ object. The close callback
20 // is not made into javascript land.
21 //
22 // - uv_ref, uv_unref counts are managed at this layer to avoid needless
23 // js/c++ boundary crossing. At the javascript layer that should all be
24 // taken care of.
25
0c7bf81 @ry Abstract out HandleWrap class
ry authored
26 class HandleWrap {
27 public:
28 static void Initialize(v8::Handle<v8::Object> target);
29 static v8::Handle<v8::Value> Close(const v8::Arguments& args);
30
31 protected:
32 HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle);
33 virtual ~HandleWrap();
34
187fe27 stdio binding + javascript to enable process.stdin.listen()
Igor Zinkovsky authored
35 virtual void SetHandle(uv_handle_t* h);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
36 virtual void StateChange() {}
37
38 v8::Persistent<v8::Object> object_;
39
40 private:
41 static void OnClose(uv_handle_t* handle);
42 // Using double underscore due to handle_ member in tcp_wrap. Probably
43 // tcp_wrap should rename it's member to 'handle'.
44 uv_handle_t* handle__;
45 };
46
47
48 } // namespace node
49
50
51 #endif // HANDLE_WRAP_H_
Something went wrong with that request. Please try again.