Comparison

net/server_select.lua @ 9576:913a17d6c449

net.server_select: Move code from :lock_read into :pause and :resume
author Kim Alvefur <zash@zash.se>
date Sun, 28 Oct 2018 16:53:10 +0100
parent 9574:03214e6e3272
child 9577:388b93b3eecf
comparison
equal deleted inserted replaced
9575:1fb3e7c550bf 9576:913a17d6c449
457 return bufferlen, maxreadlen, maxsendlen 457 return bufferlen, maxreadlen, maxsendlen
458 end 458 end
459 handler.lock_read = function (self, switch) 459 handler.lock_read = function (self, switch)
460 out_error( "server.lua, lock_read() is deprecated, use pause() and resume()" ) 460 out_error( "server.lua, lock_read() is deprecated, use pause() and resume()" )
461 if switch == true then 461 if switch == true then
462 local tmp = _readlistlen 462 return self:pause()
463 _readlistlen = removesocket( _readlist, socket, _readlistlen )
464 _readtimes[ handler ] = nil
465 if _readlistlen ~= tmp then
466 noread = true
467 end
468 elseif switch == false then 463 elseif switch == false then
469 if noread then 464 return self:resume()
470 noread = false
471 _readlistlen = addsocket(_readlist, socket, _readlistlen)
472 _readtimes[ handler ] = _currenttime
473 end
474 end 465 end
475 return noread 466 return noread
476 end 467 end
477 handler.pause = function (self) 468 handler.pause = function (self)
478 return self:lock_read(true); 469 local tmp = _readlistlen
470 _readlistlen = removesocket( _readlist, socket, _readlistlen )
471 _readtimes[ handler ] = nil
472 if _readlistlen ~= tmp then
473 noread = true
474 end
475 return noread;
479 end 476 end
480 handler.resume = function (self) 477 handler.resume = function (self)
481 return self:lock_read(false); 478 if noread then
479 noread = false
480 _readlistlen = addsocket(_readlist, socket, _readlistlen)
481 _readtimes[ handler ] = _currenttime
482 end
483 return noread;
482 end 484 end
483 handler.lock = function( self, switch ) 485 handler.lock = function( self, switch )
484 handler.lock_read (switch) 486 handler.lock_read (switch)
485 if switch == true then 487 if switch == true then
486 handler.write = idfalse 488 handler.write = idfalse