Browse Source

Rename readPause and readResume to pause/resume

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
a0c48eecab
  1. 6
      doc/api.txt
  2. 12
      src/node_net.cc
  3. 8
      src/node_net.h
  4. 4
      test/mjsunit/test-tcp-throttle-kernel-buffer.js
  5. 8
      test/mjsunit/test-tcp-throttle.js

6
doc/api.txt

@ -1451,12 +1451,12 @@ this +readyState+ will be +"readOnly"+.
Ensures that no more I/O activity happens on this socket. Only Ensures that no more I/O activity happens on this socket. Only
necessary in case of errors (parse error or so). necessary in case of errors (parse error or so).
+connection.readPause()+:: +connection.pause()+::
Pauses the reading of data. That is, +"data"+ events will not be emitted. Pauses the reading of data. That is, +"data"+ events will not be emitted.
Useful to throttle back an upload. Useful to throttle back an upload.
+connection.readResume()+:: +connection.resume()+::
Resumes reading if reading was paused by +readPause()+. Resumes reading after a call to +pause()+.
+connection.setTimeout(timeout)+:: +connection.setTimeout(timeout)+::
Sets the connection to timeout after +timeout+ milliseconds of inactivity on Sets the connection to timeout after +timeout+ milliseconds of inactivity on

12
src/node_net.cc

@ -100,8 +100,8 @@ void Connection::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(constructor_template, "close", Close); NODE_SET_PROTOTYPE_METHOD(constructor_template, "close", Close);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "forceClose", ForceClose); NODE_SET_PROTOTYPE_METHOD(constructor_template, "forceClose", ForceClose);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "setEncoding", SetEncoding); NODE_SET_PROTOTYPE_METHOD(constructor_template, "setEncoding", SetEncoding);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "readPause", ReadPause); NODE_SET_PROTOTYPE_METHOD(constructor_template, "pause", Pause);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "readResume", ReadResume); NODE_SET_PROTOTYPE_METHOD(constructor_template, "resume", Resume);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "setTimeout", SetTimeout); NODE_SET_PROTOTYPE_METHOD(constructor_template, "setTimeout", SetTimeout);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "setNoDelay", SetNoDelay); NODE_SET_PROTOTYPE_METHOD(constructor_template, "setNoDelay", SetNoDelay);
#if EVCOM_HAVE_GNUTLS #if EVCOM_HAVE_GNUTLS
@ -513,24 +513,24 @@ Handle<Value> Connection::GetPeerCertificate(const Arguments& args) {
} }
#endif #endif
Handle<Value> Connection::ReadPause(const Arguments& args) { Handle<Value> Connection::Pause(const Arguments& args) {
HandleScope scope; HandleScope scope;
Connection *connection = ObjectWrap::Unwrap<Connection>(args.This()); Connection *connection = ObjectWrap::Unwrap<Connection>(args.This());
assert(connection); assert(connection);
connection->ReadPause(); connection->Pause();
return Undefined(); return Undefined();
} }
Handle<Value> Connection::ReadResume(const Arguments& args) { Handle<Value> Connection::Resume(const Arguments& args) {
HandleScope scope; HandleScope scope;
Connection *connection = ObjectWrap::Unwrap<Connection>(args.This()); Connection *connection = ObjectWrap::Unwrap<Connection>(args.This());
assert(connection); assert(connection);
connection->ReadResume(); connection->Resume();
return Undefined(); return Undefined();
} }

8
src/node_net.h

@ -32,8 +32,8 @@ class Connection : public EventEmitter {
static v8::Handle<v8::Value> Close(const v8::Arguments& args); static v8::Handle<v8::Value> Close(const v8::Arguments& args);
static v8::Handle<v8::Value> ForceClose(const v8::Arguments& args); static v8::Handle<v8::Value> ForceClose(const v8::Arguments& args);
static v8::Handle<v8::Value> SetEncoding(const v8::Arguments& args); static v8::Handle<v8::Value> SetEncoding(const v8::Arguments& args);
static v8::Handle<v8::Value> ReadPause(const v8::Arguments& args); static v8::Handle<v8::Value> Pause(const v8::Arguments& args);
static v8::Handle<v8::Value> ReadResume(const v8::Arguments& args); static v8::Handle<v8::Value> Resume(const v8::Arguments& args);
static v8::Handle<v8::Value> SetTimeout(const v8::Arguments& args); static v8::Handle<v8::Value> SetTimeout(const v8::Arguments& args);
static v8::Handle<v8::Value> SetNoDelay(const v8::Arguments& args); static v8::Handle<v8::Value> SetNoDelay(const v8::Arguments& args);
@ -74,11 +74,11 @@ class Connection : public EventEmitter {
evcom_stream_force_close(&stream_); evcom_stream_force_close(&stream_);
} }
void ReadPause() { void Pause() {
evcom_stream_read_pause(&stream_); evcom_stream_read_pause(&stream_);
} }
void ReadResume() { void Resume() {
evcom_stream_read_resume(&stream_); evcom_stream_read_resume(&stream_);
} }

4
test/mjsunit/test-tcp-throttle-kernel-buffer.js

@ -31,14 +31,14 @@ client.addListener("data", function (d) {
chars_recved += d.length; chars_recved += d.length;
puts("got " + chars_recved); puts("got " + chars_recved);
if (!paused) { if (!paused) {
client.readPause(); client.pause();
npauses += 1; npauses += 1;
paused = true; paused = true;
puts("pause"); puts("pause");
x = chars_recved; x = chars_recved;
setTimeout(function () { setTimeout(function () {
assert.equal(chars_recved, x); assert.equal(chars_recved, x);
client.readResume(); client.resume();
puts("resume"); puts("resume");
paused = false; paused = false;
}, 100); }, 100);

8
test/mjsunit/test-tcp-throttle.js

@ -33,21 +33,21 @@ setTimeout(function () {
chars_recved = recv.length; chars_recved = recv.length;
puts("pause at: " + chars_recved); puts("pause at: " + chars_recved);
assert.equal(true, chars_recved > 1); assert.equal(true, chars_recved > 1);
client.readPause(); client.pause();
setTimeout(function () { setTimeout(function () {
puts("resume at: " + chars_recved); puts("resume at: " + chars_recved);
assert.equal(chars_recved, recv.length); assert.equal(chars_recved, recv.length);
client.readResume(); client.resume();
setTimeout(function () { setTimeout(function () {
chars_recved = recv.length; chars_recved = recv.length;
puts("pause at: " + chars_recved); puts("pause at: " + chars_recved);
client.readPause(); client.pause();
setTimeout(function () { setTimeout(function () {
puts("resume at: " + chars_recved); puts("resume at: " + chars_recved);
assert.equal(chars_recved, recv.length); assert.equal(chars_recved, recv.length);
client.readResume(); client.resume();
}, 500); }, 500);

Loading…
Cancel
Save