Skip to content

Commit

Permalink
Added utility functions fully moved from V8 to Isolate.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoopa committed Jan 17, 2015
1 parent 4dafe32 commit 3a4585c
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ NAN_METHOD(CalculateAsync) {
* <a href="#api_nan_remove_gc_epilogue_callback"><b><code>NanRemoveGCEpilogueCallback</code></b></a>
* <a href="#api_nan_remove_gc_prologue_callback"><b><code>NanRemoveGCPrologueCallback</code></b></a>
* <a href="#api_nan_get_heap_statistics"><b><code>NanGetHeapStatistics</code></b></a>
* <a href="#api_nan_set_counter_function"><b><code>NanSetCounterFunction</code></b></a>
* <a href="#api_nan_set_create_histogram_function"><b><code>NanSetCreateHistogramFunction</code></b></a>
* <a href="#api_nan_set_add_histogram_sample_function"><b><code>NanSetAddHistogramSampleFunction</code></b></a>
* <a href="#api_nan_idle_notification"><b><code>NanIdleNotification</code></b></a>
* <a href="#api_nan_low_memory_notification"><b><code>NanLowMemoryNotification</code></b></a>
* <a href="#api_nan_context_disposed_notification"><b><code>NanContextDisposedNotification</code></b></a>
* <a href="#api_nan_callback"><b><code>NanCallback</code></b></a>
* <a href="#api_nan_async_worker"><b><code>NanAsyncWorker</code></b></a>
* <a href="#api_nan_async_queue_worker"><b><code>NanAsyncQueueWorker</code></b></a>
Expand Down Expand Up @@ -1097,6 +1103,36 @@ Simply does `RemoveGCPrologueCallback`
Simply does `GetHeapStatistics`
<a name="api_nan_set_counter_function"></a>
### NanSetCounterFunction(CounterLookupCallback cb)
Simply does `SetCounterFunction`
<a name="api_nan_set_create_histogram_function"></a>
### NanSetCreateHistogramFunction(CreateHistogramCallback cb)
Simply does `SetCreateHistogramFunction`
<a name="api_nan_set_add_histogram_sample_function"></a>
### NanSetAddHistogramSampleFunction(AddHistogramSampleCallback cb)
Simply does `SetAddHistogramSampleFunction`
<a name="api_nan_idle_notification"></a>
### NanIdleNotification(int idle_time_in_ms)
Simply does `IdleNotification`
<a name="api_nan_low_memory_notification"></a>
### NanLowMemoryNotification()
Simply does `LowMemoryNotification`
<a name="api_nan_context_disposed_notification"></a>
### NanContextDisposedNotification()
Simply does `ContextDisposedNotification`
<a name="api_nan_callback"></a>
### NanCallback
Expand Down
56 changes: 56 additions & 0 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,62 @@ NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
return val;
}

#if NODE_MODULE_VERSION >= 42 // io.js 1.0
NAN_INLINE
void NanSetCounterFunction(v8::CounterLookupCallback cb) {
v8::Isolate::GetCurrent()->SetCounterFunction(cb);
}

NAN_INLINE
void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) {
v8::Isolate::GetCurrent()->SetCreateHistogramFunction(cb);
}

NAN_INLINE
void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) {
v8::Isolate::GetCurrent()->SetAddHistogramSampleFunction(cb);
}

NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) {
return v8::Isolate::GetCurrent()->IdleNotification(idle_time_in_ms);
}

NAN_INLINE void NanLowMemoryNotification() {
v8::Isolate::GetCurrent()->LowMemoryNotification();
}

NAN_INLINE void NanContextDisposedNotification() {
v8::Isolate::GetCurrent()->ContextDisposedNotification();
}
#else
NAN_INLINE
void NanSetCounterFunction(v8::CounterLookupCallback cb) {
v8::V8::SetCounterFunction(cb);
}

NAN_INLINE
void NanSetCreateHistogramFunction(v8::CreateHistogramCallback cb) {
v8::V8::SetCreateHistogramFunction(cb);
}

NAN_INLINE
void NanSetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb) {
v8::V8::SetAddHistogramSampleFunction(cb);
}

NAN_INLINE bool NanIdleNotification(int idle_time_in_ms) {
return v8::V8::IdleNotification(idle_time_in_ms);
}

NAN_INLINE void NanLowMemoryNotification() {
v8::V8::LowMemoryNotification();
}

NAN_INLINE void NanContextDisposedNotification() {
v8::V8::ContextDisposedNotification();
}
#endif

#if (NODE_MODULE_VERSION > 0x000B)
// Node 0.11+ (0.11.12 and below won't compile with these)

Expand Down

0 comments on commit 3a4585c

Please sign in to comment.