Giter VIP home page Giter VIP logo

lua-coronest's Introduction

Build status Chat

Coroutines that allow nesting

Coroutines are a powerful notion to suspend and resume execution of lightweight threads. It can be used for instance for scheduling, as in copas, or for iteration.

When mixing these two uses, a problem arises: there is no way to specify which coroutine.resume should intercept a coroutine.yield.

This module provides a thin wrapper around the standard coroutine module to allow the definition of complex behaviors with nested coroutines.

Install

This module is available in luarocks:

    luarocks install coronest

Usage

Everywhere you are using the standard Lua coroutine module, replace it with an instance of the nested coroutines:

    local coroutine = require "coroutine.make" ()

For an example, please look at examples/usage.lua.

Compatibility and Testing

Nested coroutines should be compatible with any version of Lua supporting coroutines (well, at least from 5.1). As the module is written in pure Lua, it also works with LuaJIT.

This module comes with some tests:

  • tests/nested.lua are important checks on the behavior of nested coroutines;
  • tests/lua-5.*.lua are tests imported from the Lua testsuite, but using coroutine.make instead of standard coroutines; they allow to check that nested coroutines do not break anything.

Contributors

This module has been built after this discussion on StackOverflow. Even if Alban Linard (saucisson) owns this repository, the main contributor is Philipp Janda (siffiejoe).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.