{"id":21965766,"url":"https://github.com/arkaeriit/luathreading","last_synced_at":"2025-10-10T11:30:45.578Z","repository":{"id":119303937,"uuid":"284035552","full_name":"Arkaeriit/luaThreading","owner":"Arkaeriit","description":"Bring multithreading to Lua","archived":false,"fork":false,"pushed_at":"2023-10-27T13:15:49.000Z","size":41,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-29T12:53:33.788Z","etag":null,"topics":["lua","multithreading","pthreads"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Arkaeriit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-07-31T12:48:54.000Z","updated_at":"2024-07-18T23:41:23.000Z","dependencies_parsed_at":"2023-10-27T14:29:23.373Z","dependency_job_id":null,"html_url":"https://github.com/Arkaeriit/luaThreading","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkaeriit%2FluaThreading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkaeriit%2FluaThreading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkaeriit%2FluaThreading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arkaeriit%2FluaThreading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arkaeriit","download_url":"https://codeload.github.com/Arkaeriit/luaThreading/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235946843,"owners_count":19070500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","multithreading","pthreads"],"created_at":"2024-11-29T12:51:46.224Z","updated_at":"2025-10-10T11:30:40.293Z","avatar_url":"https://github.com/Arkaeriit.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lua Threading\n\nThis library lets you easily do multi-threading in Lua.\n\n# User manual\n\n## Example\n\n```lua\nlocal luathreading = require \"luathreading\"\n--launch the function myfunc with myarg as the only argument\nlocal thread = luathreading.launch_thread(myfunc, myarg)\n--wait for the thread to end and get the return value of myfunc\nlocal result = thread:join()\n```\n\nA more detailed example is to be found in the example folder of this repo, under the name example.lua.\n\n## API\n\n### Threads\n\nThreads are created with the function `launch_thread`. This function makes a new Lua thread in the Lua state and executes it in a separate POSIX thread. The threads starts to run when it is created.\n\nThe function `launch_thread` takes as first argument the function that will be ran in the new thread and any additional arguments will be given to the function being launched.\n\nTo wait for a thread to be finished and get it's return value, you should use the `join` method of the thread. The `join` method returns the return value of the launched function. If the launched function does not return anything, the `join` method will return `nil`. If the launched function returns multiple values, only the last value will be returned. If you really need to return multiple arguments in a function, you should pack them in a table.\n\nWhen the handle to a thread is lost, the thread will still continue to run. But generating threads without joining them will create a memory leak.\n\nWhen giving values as argument to a new thread or getting return values from a thread, nil, number, booleans, strings, light userdata, and C functions are exchanged by value while lua functions, threads, tables, and userdata are exchanged by reference.\n\n### Mutexes\n\nTo synchronize threads or protecting resources used by multiple threads, Lua Threading can generate mutexes with the `new_mutex` function. Those mutexes have `lock` and `unlock` method and are generated in the unlocked state.\n\nAs there is not a lot of fine control on memory in Lua, values used by multiple threads should always be protected by mutexes. Values given as argument to thread by reference such as table should be protected if they are used in the child thread and the parent thread at the same time.\n\nMutexes are garbage collected so using them should not cause memory leak.\n\n## Installation\n\nTo install Lua Threading you must have Lua installed in your system. If so, simply run `make \u0026\u0026 make install` from the root of this repository and the library will be installed. You can test it by going into the example folder and running `./example.lua`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkaeriit%2Fluathreading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farkaeriit%2Fluathreading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farkaeriit%2Fluathreading/lists"}