1 // Copyright Joyent, Inc. and other Node contributors.
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:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
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.
22 #ifndef SRC_ASYNC_WRAP_H_
23 #define SRC_ASYNC_WRAP_H_
25 #include "base-object.h"
31 class AsyncWrap : public BaseObject {
35 HAS_ASYNC_LISTENER = 1
39 PROVIDER_NONE = 1 << 0,
40 PROVIDER_CARES = 1 << 1,
41 PROVIDER_CONNECTWRAP = 1 << 2,
42 PROVIDER_CRYPTO = 1 << 3,
43 PROVIDER_FSEVENTWRAP = 1 << 4,
44 PROVIDER_GETADDRINFOREQWRAP = 1 << 5,
45 PROVIDER_PIPEWRAP = 1 << 6,
46 PROVIDER_PROCESSWRAP = 1 << 7,
47 PROVIDER_REQWRAP = 1 << 8,
48 PROVIDER_SHUTDOWNWRAP = 1 << 9,
49 PROVIDER_SIGNALWRAP = 1 << 10,
50 PROVIDER_STATWATCHER = 1 << 11,
51 PROVIDER_TCPWRAP = 1 << 12,
52 PROVIDER_TIMERWRAP = 1 << 13,
53 PROVIDER_TLSWRAP = 1 << 14,
54 PROVIDER_TTYWRAP = 1 << 15,
55 PROVIDER_UDPWRAP = 1 << 16,
56 PROVIDER_ZLIB = 1 << 17
59 inline AsyncWrap(Environment* env,
60 v8::Handle<v8::Object> object,
61 ProviderType provider);
65 inline bool has_async_listener();
67 inline uint32_t provider_type() const;
69 // Only call these within a valid HandleScope.
70 inline v8::Handle<v8::Value> MakeCallback(const v8::Handle<v8::Function> cb,
72 v8::Handle<v8::Value>* argv);
73 inline v8::Handle<v8::Value> MakeCallback(const v8::Handle<v8::String> symbol,
75 v8::Handle<v8::Value>* argv);
76 inline v8::Handle<v8::Value> MakeCallback(uint32_t index,
78 v8::Handle<v8::Value>* argv);
83 // TODO(trevnorris): BURN IN FIRE! Remove this as soon as a suitable
84 // replacement is committed.
85 inline v8::Handle<v8::Value> MakeDomainCallback(
86 const v8::Handle<v8::Function> cb,
88 v8::Handle<v8::Value>* argv);
90 uint32_t async_flags_;
91 uint32_t provider_type_;
97 #endif // SRC_ASYNC_WRAP_H_