diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-03-16 00:05:18 +0300 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-03-16 00:24:15 +0300 |
commit | 8492c52e1529cf5988efd2b64e853b08a9c3a079 (patch) | |
tree | 55588f229d953c4bf0aafb095bd72ac57279190e /src/node_stat_watcher.h | |
parent | 627fb5adbbc324fae657d2c88523234e6d83cc1c (diff) |
Use uniform watcher names
Diffstat (limited to 'src/node_stat_watcher.h')
-rw-r--r-- | src/node_stat_watcher.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h new file mode 100644 index 00000000000..078a11f62db --- /dev/null +++ b/src/node_stat_watcher.h @@ -0,0 +1,45 @@ +// Copyright 2009 Ryan Dahl <ry@tinyclouds.org> +#ifndef NODE_STAT_WATCHER_H_ +#define NODE_STAT_WATCHER_H_ + +#include <node.h> +#include <node_events.h> +#include <ev.h> + +namespace node { + +class StatWatcher : EventEmitter { + public: + static void Initialize(v8::Handle<v8::Object> target); + + protected: + static v8::Persistent<v8::FunctionTemplate> constructor_template; + + StatWatcher() : EventEmitter() { + persistent_ = false; + path_ = NULL; + ev_init(&watcher_, StatWatcher::Callback); + watcher_.data = this; + } + + ~StatWatcher() { + Stop(); + assert(path_ == NULL); + } + + static v8::Handle<v8::Value> New(const v8::Arguments& args); + static v8::Handle<v8::Value> Start(const v8::Arguments& args); + static v8::Handle<v8::Value> Stop(const v8::Arguments& args); + + private: + static void Callback(EV_P_ ev_stat *watcher, int revents); + + void Stop(); + + ev_stat watcher_; + bool persistent_; + char *path_; +}; + +} // namespace node +#endif // NODE_STAT_WATCHER_H_ |