moonbridge

diff reference.txt @ 152:2a5bd37034c6

Removed moonbridge_io.run(...); yielding read and write methods do not yield any values
author jbe
date Fri May 15 16:42:50 2015 +0200 (2015-05-15)
parents 1939ffe973e0
children 97d3ca77c86a
line diff
     1.1 --- a/reference.txt	Fri May 08 03:35:32 2015 +0200
     1.2 +++ b/reference.txt	Fri May 15 16:42:50 2015 +0200
     1.3 @@ -121,8 +121,8 @@
     1.4  
     1.5  ### socket:flush_call(waitfunc, ...)
     1.6  
     1.7 -Same as socket:flush(...), but calls waitfunc(socket, "w") (in an infinite
     1.8 -loop) as long as the writing is blocked.
     1.9 +Same as socket:flush(...), but calls waitfunc() (in an infinite loop) as long
    1.10 +as the writing is blocked.
    1.11  
    1.12  
    1.13  ### socket:flush_nb(...)
    1.14 @@ -187,9 +187,8 @@
    1.15  
    1.16  ### socket:read_call(waitfunc, maxlen, terminator)
    1.17  
    1.18 -Same as socket:read(maxlen, terminator), but calls waitfunc(
    1.19 -moonbridge_io.block, socket, "r") (in an infinite loop) as long as the reading
    1.20 -is blocked.
    1.21 +Same as socket:read(maxlen, terminator), but calls waitfunc() (in an infinite
    1.22 +loop) as long as the reading is blocked.
    1.23  
    1.24  
    1.25  ### socket:read_nb(maxlen, terminator)
    1.26 @@ -256,8 +255,8 @@
    1.27  
    1.28  ### socket:write_call(waitfunc, ...)
    1.29  
    1.30 -Same as socket:write(...), but calls waitfunc(moonbridge_io.block, socket,
    1.31 -"w") (in an infinite loop) as long as the writing is blocked.
    1.32 +Same as socket:write(...), but calls waitfunc() (in an infinite loop) as long
    1.33 +as the writing is blocked.
    1.34  
    1.35  
    1.36  ### socket:write_nb(...)
    1.37 @@ -293,18 +292,6 @@
    1.38  listed below.
    1.39  
    1.40  
    1.41 -### moonbridge_io.block
    1.42 -
    1.43 -An opaque value (lightuserdata) used by yielding non-blocking I/O functions.
    1.44 -
    1.45 -When socket:read_yield(...) could not read from a socket, it yields the three
    1.46 -values moonbridge_io.block, the socket, and the string "r".
    1.47 -When socket:write_yield(...) could not write to a socket, it yields the three
    1.48 -values moonbridge_io.block, the socket, and the string "w".
    1.49 -
    1.50 -See reference for moonbridge_io.run(...) for further information.
    1.51 -
    1.52 -
    1.53  ### moonbridge_io.localconnect(path)
    1.54  
    1.55  Tries to connect to a local socket (also known as Unix Domain Socket). Returns
    1.56 @@ -352,12 +339,6 @@
    1.57  nil (as first return value) plus an error message (as second return value).
    1.58  
    1.59  
    1.60 -### moonbridge_io.multiblock
    1.61 -
    1.62 -An opaque value (lightuserdata) used by yielding non-blocking I/O functions.
    1.63 -See reference for moonbridge_io.run(...) for further information.
    1.64 -
    1.65 -
    1.66  ### moonbridge_io.poll(input_set, output_set, timeout)
    1.67  
    1.68  This function waits for at least one of the given file descriptors and/or
    1.69 @@ -371,77 +352,6 @@
    1.70  received.
    1.71  
    1.72  
    1.73 -### moonbridge_io.run(function_set, timeout_or_poll_func)
    1.74 -
    1.75 -Executes multiple coroutines (created via coroutine.wrap(...)) in the following
    1.76 -way:
    1.77 -
    1.78 -    function moonbridge_io.run(function_set, timeout_or_poll_func)
    1.79 -      local pairs = function(t) return next, t end  -- raw pairs
    1.80 -      local starttime = moonbridge_io.timeref()
    1.81 -      local read_fds, write_fds = {}, {}
    1.82 -      while true do
    1.83 -        local work_to_do = false
    1.84 -        for func, result_handler in pairs(function_set) do
    1.85 -          ::again::
    1.86 -          local res = table.pack(func())
    1.87 -          if res[1] == moonbridge_io.block then
    1.88 -            if string.match(res[3], "r") then
    1.89 -              read_fds[res[2]] = true
    1.90 -            end
    1.91 -            if string.match(res[3], "w") then
    1.92 -              write_fds[res[2]] = true
    1.93 -            end
    1.94 -            work_to_do = true
    1.95 -          elseif res[1] == moonbridge_io.multiblock then
    1.96 -            for fd, active in pairs(res[2]) do
    1.97 -              if active then read_fds[fd] = true end
    1.98 -            end
    1.99 -            for fd, active in pairs(res[3]) do
   1.100 -              if active then write_fds[fd] = true end
   1.101 -            end
   1.102 -            work_to_do = true
   1.103 -          else
   1.104 -            if
   1.105 -              result_handler == true or
   1.106 -              result_handler(table.unpack(res, 1, res.n))
   1.107 -            then
   1.108 -              function_set[func] = nil  -- task finished
   1.109 -            else
   1.110 -              goto again
   1.111 -            end
   1.112 -          end
   1.113 -        end
   1.114 -        if not work_to_do then
   1.115 -          return true  -- all tasks finished
   1.116 -        end
   1.117 -        if type(timeout_or_poll_func) == "function" then
   1.118 -          local poll_func = timeout_or_poll_func
   1.119 -          if
   1.120 -            poll_func(moonbridge_io.multiblock, read_fds, write_fds) == false
   1.121 -          then
   1.122 -            return false
   1.123 -          end
   1.124 -        elseif type(timeout_or_poll_func) == "number" then
   1.125 -          local timeout = timeout_or_poll_func
   1.126 -          if
   1.127 -            moonbridge_io.poll(
   1.128 -              read_fds,
   1.129 -              write_fds,
   1.130 -              timeout - moonbridge_io.timeref(starttime)
   1.131 -            ) == false
   1.132 -          then
   1.133 -            return false  -- timeout
   1.134 -          end
   1.135 -        else
   1.136 -          moonbridge_io.poll(read_fds, write_fds)
   1.137 -        end
   1.138 -        for fd in pairs(read_fds)  do read_fds[fd]  = nil end
   1.139 -        for fd in pairs(write_fds) do write_fds[fd] = nil end
   1.140 -      end
   1.141 -    end
   1.142 -
   1.143 -
   1.144  ### moonbridge_io.tcpconnect(hostname, port)
   1.145  
   1.146  Tries to open a TCP connection with the given host and TCP port number. Returns

Impressum / About Us