You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

#ifndef node_events_h
#define node_events_h
#include "node.h"
#include <v8.h>
namespace node {
class EventEmitter : public ObjectWrap {
16 years ago
public:
static void Initialize (v8::Local<v8::FunctionTemplate> ctemplate);
static v8::Persistent<v8::FunctionTemplate> constructor_template;
bool Emit (const char *event, int argc, v8::Handle<v8::Value> argv[]);
protected:
static v8::Handle<v8::Value> Emit (const v8::Arguments& args);
EventEmitter () : ObjectWrap () { }
16 years ago
};
class Promise : public EventEmitter {
public:
static void Initialize (v8::Handle<v8::Object> target);
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static Promise* Create (void);
16 years ago
bool EmitSuccess (int argc, v8::Handle<v8::Value> argv[]);
bool EmitError (int argc, v8::Handle<v8::Value> argv[]);
void Block ();
16 years ago
v8::Handle<v8::Object> Handle ()
{
return handle_;
}
16 years ago
protected:
static v8::Handle<v8::Value> New (const v8::Arguments& args);
static v8::Handle<v8::Value> Block (const v8::Arguments& args);
static v8::Handle<v8::Value> EmitSuccess (const v8::Arguments& args);
static v8::Handle<v8::Value> EmitError (const v8::Arguments& args);
16 years ago
virtual void Detach (void);
bool blocking_;
Promise *prev_; /* for the prev in the Poor Man's coroutine stack */
void Destack ();
Promise () : EventEmitter()
{
blocking_ = false;
prev_ = NULL;
}
};
} // namespace node
#endif