{"id":32985700,"url":"https://github.com/askyrme/luaproc","last_synced_at":"2026-01-11T03:43:01.169Z","repository":{"id":65470825,"uuid":"825029","full_name":"askyrme/luaproc","owner":"askyrme","description":"luaproc is a concurrent programming library for Lua","archived":false,"fork":false,"pushed_at":"2017-07-29T16:02:06.000Z","size":333,"stargazers_count":115,"open_issues_count":2,"forks_count":28,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-05-02T13:21:09.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/askyrme.png","metadata":{"files":{"readme":"README","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-08-08T18:51:45.000Z","updated_at":"2024-04-10T22:47:19.000Z","dependencies_parsed_at":"2023-01-25T00:30:34.250Z","dependency_job_id":null,"html_url":"https://github.com/askyrme/luaproc","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/askyrme/luaproc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askyrme%2Fluaproc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askyrme%2Fluaproc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askyrme%2Fluaproc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askyrme%2Fluaproc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/askyrme","download_url":"https://codeload.github.com/askyrme/luaproc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askyrme%2Fluaproc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284734138,"owners_count":27054622,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-11-13T08:00:33.767Z","updated_at":"2025-11-16T16:01:04.645Z","avatar_url":"https://github.com/askyrme.png","language":"C","funding_links":[],"categories":["资源","C","Resources"],"sub_categories":["Concurrency and Multithreading","Multitasking"],"readme":"# luaproc - A concurrent programming library for Lua\n\n## Introduction\n\nluaproc is a Lua (http://www.lua.org) extension library for concurrent\nprogramming. This text provides some background information and also serves as s\nreference manual for the library. The library is available under the same terms\nand conditions (http://www.lua.org/copyright.html) as the Lua language, the MIT\nlicense. The idea is that if you can use Lua in a project, you should also be\nable to use luaproc.\n\nLua natively supports cooperative multithreading by means of coroutines.\nHowever, coroutines in Lua cannot be executed in parallel. luaproc overcomes\nthat restriction by building on the proposal and sample implementation presented\nin Programming in Lua (http://www.inf.puc-rio.br/~roberto/pil2) (chapter 30).\nIt uses coroutines and multiple independent states in Lua to implement Lua\nprocesses, which are user threads comprised of Lua code that have no shared\ndata. Lua processes are executed by workers, which are system threads\nimplemented with POSIX threads (pthreads), and thus can run in parallel.\n\nCommunication between Lua processes relies exclusively on message passing. Each\nmessage can carry a tuple of atomic Lua values (strings, numbers, booleans and\nnil). More complex types must be encoded somehow -- for instance by using\nstrings of Lua code that when executed return such a type. Message addressing is\nbased on communication channels, which are decoupled from Lua processes and must\nbe explicitly created.\n\nSending a message is always a synchronous operation, i.e., the send operation\nonly returns after a message has been received by another Lua process or if an\nerror occurs (such as trying to send a message to a non-existent channel).\nReceiving a message, on the other hand, can be a synchronous or asynchronous\noperation. In synchronous mode, a call to the receive operation only returns\nafter a message has been received or if an error occurs. In asynchronous mode, a\ncall to the receive operation returns immediately and indicates if a message was\nreceived or not.\n\nIf a Lua process tries to send a message to a channel where there are no Lua\nprocesses waiting to receive a message, its execution is suspended until a\nmatching receive occurs or the channel is destroyed. The same happens if a Lua\nprocess tries to synchronously receive a message from a channel where there are\nno Lua processes waiting to send a message.\n\nluaproc also offers an optional facility to recycle Lua processes. Recycling\nconsists of reusing states from finished Lua processes, instead of destroying\nthem. When recycling is enabled, a new Lua process can be created by loading its\ncode in a previously used state from a finished Lua process, instead of creating\na new state. \n\n## Compatibility\n\nluaproc is compatible with Lua 5.1, 5.2 and 5.3.\n\n## API\n\n`luaproc.newproc( string lua_code )`\n`luaproc.newproc( function f )`\n\nCreates a new Lua process to run the specified string of Lua code or the\nspecified Lua function. Returns true if successful or nil and an error message\nif failed. The only libraries loaded in new Lua processes are luaproc itself and\nthe standard Lua base and package libraries. The remaining standard Lua\nlibraries (io, os, table, string, math, debug, coroutine and utf8) are\npre-registered and can be loaded with a call to the standard Lua function\n`require`. \n\n`luaproc.setnumworkers( int number_of_workers )`\n\nSets the number of active workers (pthreads) to n (default = 1, minimum = 1).\nCreates and destroys workers as needed, depending on the current number of\nactive workers. No return, raises error if worker could not be created. \n\n`luaproc.getnumworkers( )`\n\nReturns the number of active workers (pthreads). \n\n`luaproc.wait( )`\n\nWaits until all Lua processes have finished, then continues program execution.\nIt only makes sense to call this function from the main Lua script. Moreover,\nthis function is implicitly called when the main Lua script finishes executing.\nNo return. \n\n`luaproc.recycle( int maxrecycle )`\n\nSets the maximum number of Lua processes to recycle. Returns true if successful\nor nil and an error message if failed. The default number is zero, i.e., no Lua\nprocesses are recycled. \n\n`luaproc.send( string channel_name, msg1, [msg2], [msg3], [...] )`\n\nSends a message (tuple of boolean, nil, number or string values) to a channel.\nReturns true if successful or nil and an error message if failed. Suspends\nexecution of the calling Lua process if there is no matching receive. \n\n`luaproc.receive( string channel_name, [boolean asynchronous] )`\n\nReceives a message (tuple of boolean, nil, number or string values) from a\nchannel. Returns received values if successful or nil and an error message if\nfailed. Suspends execution of the calling Lua process if there is no matching\nreceive and the async (boolean) flag is not set. The async flag, by default, is\nnot set. \n\n`luaproc.newchannel( string channel_name )`\n\nCreates a new channel identified by string name. Returns true if successful or\nnil and an error message if failed.\n\n`luaproc.delchannel( string channel_name )`\n\nDestroys a channel identified by string name. Returns true if successful or nil\nand an error message if failed. Lua processes waiting to send or receive\nmessages on destroyed channels have their execution resumed and receive an error\nmessage indicating the channel was destroyed. \n\n## References\n\nA paper about luaproc -- Exploring Lua for Concurrent Programming -- was\npublished in the Journal of Universal Computer Science and is available\nhere (http://www.jucs.org/jucs_14_21/exploring_lua_for_concurrent) and\nhere (http://www.inf.puc-rio.br/~roberto/docs/ry08-05.pdf). Some information in\nthe paper is already outdated, but it still provides a good overview of the\nlibrary and some of its design choices.\n\nA tech report about concurrency in Lua, which uses luaproc as part of a case\nstudy, is also available\nhere (ftp://ftp.inf.puc-rio.br/pub/docs/techreports/11_13_skyrme.pdf).\n\nFinally, a paper about an experiment to port luaproc to use Transactional Memory\ninstead of the standard POSIX Threads synchronization constructs, published as a\npart of the 8th ACM SIGPLAN Workshop on Transactional Computing, can be found\nhere (http://transact2013.cse.lehigh.edu/skyrme.pdf).\n\n## Download\n\nGitHub source repository: https://github.com/askyrme/luaproc.\n\n## License\n\nCopyright © 2008-2015 Alexandre Skyrme, Noemi Rodriguez, Roberto Ierusalimschy.\nAll rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskyrme%2Fluaproc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faskyrme%2Fluaproc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskyrme%2Fluaproc/lists"}