Changeset

3000:43a4cb707fe4

net.server_select, net.server_event: Support for :pause() and :resume() on connections
author Matthew Wild <mwild1@gmail.com>
date Wed, 05 May 2010 15:21:17 +0100
parents 2988:0c61f73ac0fb
children 3001:fa00c6f563b4
files net/server_event.lua net/server_select.lua
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Wed May 05 11:24:45 2010 +0100
+++ b/net/server_event.lua	Wed May 05 15:21:17 2010 +0100
@@ -282,8 +282,21 @@
 			return nointerface, noreading, nowriting
 	end
 	
+	--TODO: Deprecate
 	function interface_mt:lock_read(switch)
-		return self:_lock(self.nointerface, switch, self.nowriting);
+		if switch then
+			return self:pause();
+		else
+			return self:resume();
+		end
+	end
+
+	function interface_mt:pause()
+		return self:_lock(self.nointerface, true, self.nowriting);
+	end
+
+	function interface_mt:resume()
+		return self:_lock(self.nointerface, false, self.nowriting);
 	end
 
 	function interface_mt:counter(c)
--- a/net/server_select.lua	Wed May 05 11:24:45 2010 +0100
+++ b/net/server_select.lua	Wed May 05 15:21:17 2010 +0100
@@ -392,6 +392,7 @@
 		maxreadlen = readlen or maxreadlen
 		return bufferlen, maxreadlen, maxsendlen
 	end
+	--TODO: Deprecate
 	handler.lock_read = function (self, switch)
 		if switch == true then
 			local tmp = _readlistlen
@@ -409,6 +410,12 @@
 		end
 		return noread
 	end
+	handler.pause = function (self)
+		return self:lock_read(true);
+	end
+	handler.resume = function (self)
+		return self:lock_read(false);
+	end
 	handler.lock = function( self, switch )
 		handler.lock_read (switch)
 		if switch == true then