diff options
Diffstat (limited to 'fifo.lua')
-rw-r--r-- | fifo.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fifo.lua b/fifo.lua index 03a7af7..f3a3d10 100644 --- a/fifo.lua +++ b/fifo.lua @@ -11,7 +11,7 @@ function fifo.signal(f) end function fifo.get(f) - if not f.head then + while not f.head do f.cond:wait() end @@ -21,7 +21,13 @@ function fifo.get(f) end function fifo.put(f, data) - f.head = { data = data, tail = f.head } + local tail = f.head + while tail and tail.tail do tail = tail.tail end + if tail then + tail.tail = { data = data } + else + f.head = { data = data } + end fifo.signal(f) end |