2017-06-12 14:50:00 +03:00
2017-06-10 14:13:31 +03:00
2017-02-11 14:46:34 +03:00
2017-06-10 14:13:31 +03:00
2017-06-12 14:50:00 +03:00
2017-06-12 14:50:00 +03:00
2017-02-17 21:37:10 +03:00
2017-01-18 00:21:52 +03:00
2017-06-10 14:13:31 +03:00
2017-04-04 01:53:49 +03:00
2017-06-12 14:50:00 +03:00
2017-02-15 16:57:51 +03:00
2017-03-05 02:27:11 +03:00

Effil

Lua library for real multithreading. Written in C++ with great help of sol2.

Build Status Documentation Status

How to install

Build from src on Linux and Mac

  1. git clone git@github.com:loud-hound/effil.git effil && cd effil
  2. mkdir build && cd build && make -j4
  3. Add libeffil.so or libeffil.dylib to your lua package.path.

From lua rocks

Coming soon.

Quick guide for impatient

As you may now there are not much script languages with real multithreading support (Lua/Python/Ruby and etc has global interpreter lock aka GIL). Effil solves this problem by running independent Lua VM in separate native thread and provides robust communicating primitives for creating threads (VM instances) and data sharing.

Effil library provides two major functions:

  1. effil.thread(action) - function which creates threads.
  2. effil.table - table that persist in all threads and behaves just like regular lua table.
  3. Bunch og utilities to handle threads and tables.

Examples

Spawn the thread

local effil = require("libeffil")
function bark(name)
    print(name .. ": bark")
end

-- associate bark with thread
-- invoke bark in separate thread with spark argument
-- wait while Sparky barks
effil.thread(bark)("Sparky"):wait()

Output: Sparky: bark

Sharing data


local effil = require("libeffil")

function download_heavy_file(url, files)
    -- i am to lazy to write real downloading here
    files[url] = "content of " .. url
end

-- shared table for data exchanging
local files = effil.table {}
local urls = {"luarocks.org", "ya.ru", "github.com"}
local downloads = {}
-- capture function for further threads
local downloader = effil.thread(download_heavy_file)

for i, url in pairs(urls) do
    -- run downloads in separate threads
    -- each invocation creates separate thread
    downloads[url] = downloader(url, files)
end

for i, url in pairs(urls) do
    -- here we go
    downloads[url]:wait()
    print("Downloaded: "  .. files[url])
end

Output:

Downloaded:File contentluarocks.org
Downloaded:File contentya.ru
Downloaded:File contentgithub.com

Reference

There is no

Description
Multithreading support for Lua
Readme MIT 348 KiB
Languages
C++ 58.8%
Lua 39.5%
CMake 1.7%