diff options
| author | ruki <[email protected]> | 2019-11-06 00:42:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-05 22:16:30 +0800 |
| commit | 3d8d86c9056c2ed4ba57e61ff0030f2749c847aa (patch) | |
| tree | 76fc4e406208a1669bb9a1fbef6b1ef7c32f6784 /xmake/core/base/socket.lua | |
| parent | fd322749574405435e4332014be8b3fa883c92d9 (diff) | |
seperate poller
Diffstat (limited to 'xmake/core/base/socket.lua')
| -rw-r--r-- | xmake/core/base/socket.lua | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/xmake/core/base/socket.lua b/xmake/core/base/socket.lua index 8992995e9..4a2dfdcdc 100644 --- a/xmake/core/base/socket.lua +++ b/xmake/core/base/socket.lua @@ -20,7 +20,6 @@ -- define module local socket = socket or {} -local _poller = _poller or {} local _instance = _instance or {} -- load modules @@ -520,78 +519,6 @@ function _instance:__gc() end end --- get socket events from poller -function _poller:events(sock) - return self._CACHE and self._CACHE[sock] or nil -end - --- set socket events to poller -function _poller:events_set(sock, events) - local cache = self._CACHE - if not cache then - cache = {} - self._CACHE = cache - end - cache[sock] = events -end - --- insert socket events to poller -function _poller:insert(sock, events) - - -- ensure opened - local ok, errors = sock:_ensure_opened() - if not ok then - return false, errors - end - - -- insert it - if not io.poller_insert(sock._SOCK, events) then - return false, string.format("insert %s events(%d) to poller failed!", sock, events) - end - - -- save this socket events and save sock/ref for gc - self:events_set(sock, events) - return true -end - --- modify socket events in poller -function _poller:modify(sock, events) - - -- ensure opened - local ok, errors = sock:_ensure_opened() - if not ok then - return false, errors - end - - -- modify it - if not io.poller_modify(sock._SOCK, events) then - return false, string.format("modify %s events(%d) to poller failed!", sock, events) - end - - -- update this socket events - self:events_set(sock, events) - return true -end - --- remove socket from poller -function _poller:remove(sock) - - -- ensure opened - local ok, errors = sock:_ensure_opened() - if not ok then - return false, errors - end - - -- remove it - if not io.poller_remove(sock._SOCK) then - return false, string.format("remove %s from poller failed!", sock) - end - - -- remove this socket events - self:events_set(sock, nil) - return true -end - -- open a socket -- -- @param socktype the socket type, e.g. tcp, udp, icmp |
