Skip to content

Instantly share code, notes, and snippets.

@polotek
Created August 9, 2010 03:10
Show Gist options
  • Save polotek/514868 to your computer and use it in GitHub Desktop.
Save polotek/514868 to your computer and use it in GitHub Desktop.
commit 4d22609d665f937985dbd0ac1b8a7f1c8c62a237
Date: Sun Aug 8 12:49:58 2010 -0400
Add process.maxIOThreads to allow managing io threads at runtime.
diff --git a/src/node.cc b/src/node.cc
index b13f7ce..ee20707 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -267,6 +267,28 @@ static void EIODonePoll(void) {
ev_async_send(EV_DEFAULT_UC_ &eio_done_poll_notifier);
}
+ static Handle<Value> GetMaxIOThreads(Local<String> name, const AccessorInfo& info) {
+ HandleScope scope;
+
+ return Integer::New(eio_nmax());
+ }
+
+ static void SetMaxIOThreads(Local<String> name,
+ Local<Value> value,
+ const AccessorInfo& info) {
+ HandleScope scope;
+
+ unsigned int val = value->Int32Value();
+ if(value->IsUint32() && val > 0) {
+ unsigned int cur_max = eio_nmax();
+ if(cur_max < val)
+ eio_set_min_parallel(val);
+ else
+ eio_set_max_parallel(val);
+ } else {
+ ThrowException(Exception::Error(String::New("Max threads must be set to a positive integer.")));
+ }
+ }
static inline const char *errno_string(int errorno) {
#define ERRNO_CASE(e) case e: return #e;
@@ -1669,6 +1691,9 @@ static void Load(int argc, char *argv[]) {
EventEmitter::constructor_template->GetFunction());
+ process->SetAccessor(String::NewSymbol("maxIOThreads"),
+ GetMaxIOThreads, SetMaxIOThreads);
+
// Initialize the C++ modules..................filename of module
IOWatcher::Initialize(process); // io_watcher.cc
// Not in use at the moment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment