0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/src/node_stat_watcher.h
Trevor Norris e56758a5e0 async-wrap: add provider id and object info cb
Re-add the wrapper class id to AsyncWrap instances so they can be
tracked directly in a heapdump.

Previously the class id was given without setting the heap dump wrapper
class info provider. Causing a segfault when a heapdump was taken. This
has been added, and the label_ set to the given provider name so each
instance can be identified.

The id will not be set of the passed object has no internal field count.
As the class pointer cannot be retrieved from the object.

In order to properly report the allocated size of each class, the new
pure virtual method self_size() has been introduces.

PR-URL: https://github.com/nodejs/io.js/pull/1896
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-17 12:58:39 -06:00

39 lines
968 B
C++

#ifndef SRC_NODE_STAT_WATCHER_H_
#define SRC_NODE_STAT_WATCHER_H_
#include "node.h"
#include "async-wrap.h"
#include "env.h"
#include "uv.h"
#include "v8.h"
namespace node {
class StatWatcher : public AsyncWrap {
public:
virtual ~StatWatcher() override;
static void Initialize(Environment* env, v8::Handle<v8::Object> target);
protected:
StatWatcher(Environment* env, v8::Local<v8::Object> wrap);
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
size_t self_size() const override { return sizeof(*this); }
private:
static void Callback(uv_fs_poll_t* handle,
int status,
const uv_stat_t* prev,
const uv_stat_t* curr);
void Stop();
uv_fs_poll_t* watcher_;
};
} // namespace node
#endif // SRC_NODE_STAT_WATCHER_H_