Skip to content

scythe/luaproc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

***************************************************
*
* Copyright 2014 Alexandre Skyrme, Noemi Rodriguez, Roberto Ierusalimschy
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* 
*****************************************************
*
* [README]                                          
*
****************************************************

-- Create a new Lua process
-- Returns true if sucessful or nil, error_message if failed
luaproc.newproc( <string lua_code> )

-- Set the number of active workers (default = 1, min = 1)
-- Creates/destroys workers depending on the number of active workers
-- No return, raises error if worker(s) could not be created
luaproc.setnumworkers( <int number_of_workers> )

-- Get the number of active workers
-- Returns the number of active workers
luaproc.getnumworkers( <void> )

-- Wait for all Lua processes to finish
-- No return
-- Obs.: It only makes sense to call this function from the main Lua script.
--       Moreover, this function is always implicitly called when the main Lua
--       script finishes executing.
luaproc.wait( <void> )

-- Set the maximum number of Lua processes that can be recycled (default = 0)
-- Returns true if sucessful or nil, error_message if failed
luaproc.recycle( <int maxrecycle> )

-- Send a message (boolean, nil, number or string) on a channel
-- Returns true if sucessful or nil, error_message if failed
-- Blocks when there is no matching receive
luaproc.send( <string channel_name>, <msg1>, [msg2], [msg3], ... )

-- Receive a message (boolean, nil, number or string) on a channel
-- Returns message(s) if sucessful or nil, error_message if failed
-- Blocks when there is no matching send and the optional asynchronous
-- flag is not set (nil) or set to false
luaproc.receive( <string channel_name>, [boolean asynchronous] )

-- Create a new channel
-- Returns true if sucessful or nil, error_message if failed
luaproc.newchannel( <string channel_name> )

-- Destroy a channel
-- Returns true if sucessful or nil, error_message if failed
luaproc.delchannel( <string channel_name> )

<> = mandatory arguments
[] = optional arguments

About

Concurrent programming library for Lua

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 92.9%
  • Makefile 5.9%
  • Lua 1.2%