forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_wrap.h
46 lines (33 loc) · 1.24 KB
/
stream_wrap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef STREAM_WRAP_H_
#define STREAM_WRAP_H_
#include <v8.h>
#include <node.h>
#include <handle_wrap.h>
namespace node {
class StreamWrap : public HandleWrap {
public:
uv_stream_t* GetStream() { return stream_; }
static void Initialize(v8::Handle<v8::Object> target);
// JavaScript functions
static v8::Handle<v8::Value> Write(const v8::Arguments& args);
static v8::Handle<v8::Value> ReadStart(const v8::Arguments& args);
static v8::Handle<v8::Value> ReadStop(const v8::Arguments& args);
static v8::Handle<v8::Value> Shutdown(const v8::Arguments& args);
protected:
StreamWrap(v8::Handle<v8::Object> object, uv_stream_t* stream);
virtual ~StreamWrap() { }
virtual void SetHandle(uv_handle_t* h);
void StateChange() { }
void UpdateWriteQueueSize();
private:
static inline char* NewSlab(v8::Handle<v8::Object> global, v8::Handle<v8::Object> wrap_obj);
// Callbacks for libuv
static void AfterWrite(uv_write_t* req, int status);
static uv_buf_t OnAlloc(uv_stream_t* handle, size_t suggested_size);
static void OnRead(uv_stream_t* handle, ssize_t nread, uv_buf_t buf);
static void AfterShutdown(uv_shutdown_t* req, int status);
size_t slab_offset_;
uv_stream_t* stream_;
};
} // namespace node
#endif // STREAM_WRAP_H_