Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 90 lines (73 sloc) 3.311 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
5f04065 @bnoordhuis process: add _getActiveHandles(), _getActiveRequests()
bnoordhuis authored
25 #include "ngx-queue.h"
26
0c7bf81 @ry Abstract out HandleWrap class
ry authored
27 namespace node {
28
85404c5 @ry Move HandleWrap rules to one place
ry authored
29 // Rules:
30 //
31 // - Do not throw from handle methods. Set errno.
32 //
33 // - MakeCallback may only be made directly off the event loop.
34 // That is there can be no JavaScript stack frames underneith it.
35 // (Is there anyway to assert that?)
36 //
37 // - No use of v8::WeakReferenceCallback. The close callback signifies that
38 // we're done with a handle - external resources can be freed.
39 //
40 // - Reusable?
41 //
42 // - The uv_close_cb is used to free the c++ object. The close callback
43 // is not made into javascript land.
44 //
45 // - uv_ref, uv_unref counts are managed at this layer to avoid needless
46 // js/c++ boundary crossing. At the javascript layer that should all be
47 // taken care of.
48
110cacd @isaacs core: Move UNWRAP_NO_ABORT to handle_wrap.h
isaacs authored
49 #define UNWRAP_NO_ABORT(type) \
50 assert(!args.Holder().IsEmpty()); \
51 assert(args.Holder()->InternalFieldCount() > 0); \
52 type* wrap = static_cast<type*>( \
53 args.Holder()->GetPointerFromInternalField(0));
54
0c7bf81 @ry Abstract out HandleWrap class
ry authored
55 class HandleWrap {
56 public:
57 static void Initialize(v8::Handle<v8::Object> target);
58 static v8::Handle<v8::Value> Close(const v8::Arguments& args);
3116522 @indutny child_process: spawn().ref() and spawn().unref()
indutny authored
59 static v8::Handle<v8::Value> Ref(const v8::Arguments& args);
7e62bc9 @ry Move process.stdout unref hack to handle_wrap.cc
ry authored
60 static v8::Handle<v8::Value> Unref(const v8::Arguments& args);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
61
5e7e51c @piscisaureus cluster: support datagram sockets
piscisaureus authored
62 inline uv_handle_t* GetHandle() { return handle__; };
63
0c7bf81 @ry Abstract out HandleWrap class
ry authored
64 protected:
65 HandleWrap(v8::Handle<v8::Object> object, uv_handle_t* handle);
66 virtual ~HandleWrap();
67
187fe27 stdio binding + javascript to enable process.stdin.listen()
Igor Zinkovsky authored
68 virtual void SetHandle(uv_handle_t* h);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
69
70 v8::Persistent<v8::Object> object_;
71
72 private:
5f04065 @bnoordhuis process: add _getActiveHandles(), _getActiveRequests()
bnoordhuis authored
73 friend v8::Handle<v8::Value> GetActiveHandles(const v8::Arguments&);
0c7bf81 @ry Abstract out HandleWrap class
ry authored
74 static void OnClose(uv_handle_t* handle);
5f04065 @bnoordhuis process: add _getActiveHandles(), _getActiveRequests()
bnoordhuis authored
75 ngx_queue_t handle_wrap_queue_;
0c7bf81 @ry Abstract out HandleWrap class
ry authored
76 // Using double underscore due to handle_ member in tcp_wrap. Probably
77 // tcp_wrap should rename it's member to 'handle'.
78 uv_handle_t* handle__;
3d20905 @bnoordhuis handle_wrap: replace unref_ field with flags_ field
bnoordhuis authored
79 unsigned int flags_;
80
81 static const unsigned int kUnref = 1;
958ab66 @bnoordhuis handle_wrap: add close callback support
bnoordhuis authored
82 static const unsigned int kCloseCallback = 2;
0c7bf81 @ry Abstract out HandleWrap class
ry authored
83 };
84
85
86 } // namespace node
87
88
89 #endif // HANDLE_WRAP_H_
Something went wrong with that request. Please try again.