Skip to content

Olivine-Labs/promise

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 

promise

Lua promises

Supports lua coroutines and nginx light threads

local p = require 'promise'()
local id = p:start(function() return 'foo', 'bar' end)
local foo, bar = p:fetch(id)

if not foo then error(bar) end

id = p:start(function() return 'foo', 'bar' end)
local id2 = p:start(function() return 'baz', 'bat' end)

local results = p:all()

local firstResults = results[id]
local secondResults = results[id2]

id = p:start(function() return 'foo', 'bar' end)
local id2 = p:start(function() return 'baz', 'bat' end)

while true do
  local id, foo, bar = p:first()
  if not id then break end
  print(foo)
  print(bar)
end

About

Lua promises

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages