GithubHelp home page GithubHelp logo

danielga / gmod_lanes Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 3.0 127 KB

Modules for Garry's Mod that add threads through Lua Lanes.

Home Page: https://github.com/danielga/gmod_lanes

License: Other

Lua 97.90% C++ 2.10%
garrys-mod garrysmod garrysmod-module gmod gmod-modules

gmod_lanes's People

Contributors

danielga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gmod_lanes's Issues

Functions are not transfered properly ('function not found in Lane destination transfer database')

[ERROR] lua/includes/modules/hook.lua:84: main: function 'ents/GetAll' not found in Lane #0x2fc3b9b8 destination transfer database.

  1. v - [C]:-1
  2. unknown - lua/includes/modules/hook.lua:84

My code:

require('lanes') 
if !lanes.gen then lanes.configure() end

local ents_GetAll = ents.GetAll
local ipairs = ipairs
local print = print

hook.Add('Think', 'lanes.test', lanes.gen(function()
    local entities = ents_GetAll()

    for k,v in ipairs(entities) do
        print(v)
    end

    return true
end))

function 'lanes_core/now_secs' not found

[ERROR] lua/includes/modules/lanes.lua:571: main: function 'lanes_core/now_secs' not found in Lane #0x27b77c30 destination transfer database.

  1. unknown - [C]:-1
  2. configure - lua/includes/modules/lanes.lua:571
    3. unknown - addons/stuff/lua/stuff/sv_lanes_test.lua:21
    4. include - [C]:-1
    5. unknown - addons/stuff/lua/autorun/stuff_load.lua:74

lanes assert failed

lua/includes/modules/lanes.lua:567: ASSERT failed: ......\lanes\src\lanes.c:2192 'nargs >= 0'

require'lanes'
lanes.configure()

Took this file https://github.com/danielga/gmod_lanes/blob/master/lanes.lua

error: timer_lane = gen( "*", { package= {}, priority = max_prio}, timer_body)() -- "*" instead of "io,package" for LuaJIT compatibility...

crash: https://github.com/danielga/gmod_lanes/releases/download/downloadables/lanes.lua

`require'lanes'
if lanes.configure then
lanes.configure()
end

function firstThread()
print('Hello World')
end

genFirstThread = lanes.gen( "*",firstThread )()`

Crash issue with lanes.gen()

So I have been having an issue today with getting the module to actually work. I'm currently running this on SRCDS default branch for windows. The issue seems to be related to the lanes.gen() function. depends on if I have the first perameter as a string or just the function. I've also tried with setting the first perameter as "" and "base" aswell with the same crash issue happening.

I tried asking on the LuaLanes repo in hopes that it was just an issue of not properly using the lanes.gen() function but I didn't really get any clue of whats causing the issue and from what I understand I am doing things correctly in my lua file.

This is the code I currently have:

require("lanes")
lanes.configure()

local e_func = lanes.gen("*",function(n)
	for i=1,n do
		print("Thead E is running")
	end
end)

local f_func = lanes.gen("*",function(n)
	for i=1,n do
		print("Thead F is running")
	end
end)


function TestLanes() --Crash happens the moment this function is called
	local E = e_func(1000)
	local F = f_func(1000)
	
	print(E[1],F[1])
end

If I remove the "*" from the lanes.gen() however, the crash does not occure. Instead I get this error happening.

[ERROR] main: function 'print' not found in Lane #0x2c2801c0 destination transfer database.

  1. e_func - [C]:-1
  2. TestLanes - gamemodes/vaasrp/gamemode/core/security_sv.lua:219
    3. unknown - lua_run:1

Question regarding one of the listed limitations of Lua_Lanes

Does this specific limitation apply to the module
"Multi-CPU is done with OS threads, not processes. A lane is a Lua full userdata, therefore it will exist only as long as the Lua state that created it still exists. Therefore, a lane won't continue execution after the main program's termination."

Specifically the part about using OS threads not processes. aswell if this limitation does apply, is there already a means of removing old lanes no longer being used when say a server shuts down? For example lets say 4 lanes were made and then the normal gmod lua state. when srcds is shut down, do these lanes get cleaned up with it or no? and if not is it possible to implement a means of cleaning them up?

Issues when trying to compile against newest garrysmod_common

Hello,

I've tried compiling gmod_lanes with most recent garrysmod_common.
While there's no recommended garrysmod_common revision specified, I think it wouldn't work with recent garry's mod versions anyways.

Here are compiler errors:

../../../lanes/src/tools.c:189:21: error: initializer element is not constant
  189 |  { LUA_LOADLIBNAME, luaopen_package},
      |                     ^~~~~~~~~~~~~~~
../../../lanes/src/tools.c:189:21: note: (near initialization for ‘libs[0].func’)
../../../lanes/src/tools.c:190:20: error: initializer element is not constant
  190 |  { LUA_TABLIBNAME, luaopen_table},
      |                    ^~~~~~~~~~~~~
../../../lanes/src/tools.c:190:20: note: (near initialization for ‘libs[1].func’)
../../../lanes/src/tools.c:191:20: error: initializer element is not constant
  191 |  { LUA_STRLIBNAME, luaopen_string},
      |                    ^~~~~~~~~~~~~~
../../../lanes/src/tools.c:191:20: note: (near initialization for ‘libs[2].func’)
../../../lanes/src/tools.c:192:21: error: initializer element is not constant
  192 |  { LUA_MATHLIBNAME, luaopen_math},
      |                     ^~~~~~~~~~~~
../../../lanes/src/tools.c:192:21: note: (near initialization for ‘libs[3].func’)
../../../lanes/src/tools.c:194:19: error: initializer element is not constant
  194 |  { LUA_OSLIBNAME, luaopen_os},
      |                   ^~~~~~~~~~
../../../lanes/src/tools.c:194:19: note: (near initialization for ‘libs[4].func’)
../../../lanes/src/tools.c:195:19: error: ‘luaopen_io’ undeclared here (not in a function); did you mean ‘luaopen_jit’?
  195 |  { LUA_IOLIBNAME, luaopen_io},
      |                   ^~~~~~~~~~
      |                   luaopen_jit
../../../lanes/src/tools.c:208:19: error: initializer element is not constant
  208 |  { LUA_DBLIBNAME, luaopen_debug},
      |                   ^~~~~~~~~~~~~
../../../lanes/src/tools.c:208:19: note: (near initialization for ‘libs[7].func’)

Notice error: ‘luaopen_io’ undeclared here (not in a function) part, it seems like it didn't even take luaopen_io declaration in main.cpp into account.

Is there any recommendations on how to resolve this issue?

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.