Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (62 sloc) 2.619 kB
60818b9 @ry Add missing copyright headers
ry authored
1 // Copyright Joyent, Inc. and other Node contributors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
0c7bf81 @ry Abstract out HandleWrap class
ry authored
22 #ifndef HANDLE_WRAP_H_
23 #define HANDLE_WRAP_H_
24
25 namespace node {
26
85404c5 @ry Move HandleWrap rules to one place
ry authored
27 // Rules:
28 //
29 // - Do not throw from handle methods. Set errno.
30 //
31 // - MakeCallback may only be made directly off the event loop.
32 // That is there can be no JavaScript stack frames underneith it.
33 // (Is there anyway to assert that?)
34 //
35 // - No use of v8::WeakReferenceCallback. The close callback signifies that
36 // we're done with a handle - external resources can be freed.
37 //
38 // - Reusable?
39 //
40 // - The uv_close_cb is used to free the c++ object. The close callback
41 // is not made into javascript land.
42 //
43 // - uv_ref, uv_unref counts are managed at this layer to avoid needless
44 // js/c++ boundary crossing. At the javascript layer that should all be
45 // taken care of.
46
0c7bf81 @ry Abstract out HandleWrap class
ry authored
47 class HandleWrap {
48 public:
49 static void Initialize(v8::Handle<v8::Object> target);
50 static v8::Handle<v8::Value> Close(const v8::Arguments& args);
7e62bc9 @ry Move process.stdout unref hack to handle_wrap.cc
ry authored
51 static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
52
53 protected:
54 HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle);
55 virtual ~HandleWrap();
56
187fe27 stdio binding + javascript to enable process.stdin.listen()
Igor Zinkovsky authored
57 virtual void SetHandle(uv_handle_t* h);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
58 virtual void StateChange() {}
59
60 v8::Persistent<v8::Object> object_;
61
62 private:
63 static void OnClose(uv_handle_t* handle);
64 // Using double underscore due to handle_ member in tcp_wrap. Probably
65 // tcp_wrap should rename it's member to 'handle'.
66 uv_handle_t* handle__;
7e62bc9 @ry Move process.stdout unref hack to handle_wrap.cc
ry authored
67 bool unref;
0c7bf81 @ry Abstract out HandleWrap class
ry authored
68 };
69
70
71 } // namespace node
72
73
74 #endif // HANDLE_WRAP_H_
Something went wrong with that request. Please try again.