Giter VIP home page Giter VIP logo

lsched's Introduction

Very simple preemptive scheduler for Lua.

lsched is a very simple preemptive scheduler for Lua.

License: MIT (see LICENSE)

Dependencies

Lua = 5.2

Compilation

To compile, just type the following command in the terminal:

make

If you are on a debian-like system and you have installed all the required dependencies, it should work as-is. If you are out of luck, you can tweak the compilation process using the following variables:

  • LUA_CFLAGS

For example, if the Lua development headers are not in a common location, you can try:

make LUA_CFLAGS="-I/path/to/lua/headers"

Documentation

The first thing to do is to create a scheduler:

local lsched = require('lsched')
local sched = lsched.new()

Then you can start adding threads to the scheduler:

sched:new_thread(function(msg) while true do print(msg) end end, 'Hello world')
-- it's also possible to specify the number of instructions a thread will
-- execute before releasing control to another thread. To do that pass an
-- integer as the first argument to the new_thread() method.
sched:new_thread(10, function() while true do print('foo') end end)

Finally run the scheduler:

sched:run()

When all threads managed by the scheduler terminate or die, the run() method returns. It is possible to add new threads to the scheduler while it is running.

lsched's People

Contributors

montag451 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chlin501

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.