GithubHelp home page GithubHelp logo

corope's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  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

corope's Issues

'rope function called outside of dispatch function or inside coroutine' when using rope:parallel

I can't seem to get the rope:parallel function to work. Everything I've tried results in the following error:

Error: corope.lua:328: rope function called outside of dispatch function or inside coroutine
stack traceback:
  [C]: in function 'error'
  tests/utils/corope.lua:157: in function 'checkCorrectCoroutine'
  tests/utils/corope.lua:296: in function 'signal'
  tests/utils/corope.lua:328: in function 'errhand'
  tests/utils/corope.lua:106: in function 'update'
  tests/coropetest.lua:6: in function 'update'
  [string "boot.lua"]:464: in function <[string "boot.lua"]:436>
  [C]: in function 'xpcall'

My simple function call for testing looks like this:

bundle(function(rope)
    rope:parallel(
        function()
            print "First"
            rope:wait(0.5)
        end,
        function()
            print "Second"
            rope:wait(1.5)
        end
    )
    print "Last"
end)

Going by the documentation, I would expect it to output:

First
Second
Last

Instead it throws the error message shown above.

Would it be possible to get an example showing how the Parallel function is meant to be used?

I want to implement it in it. could you tell me, please, how to do this?

thank you very much for your library. I want to implement it in it. could you tell me, please, how to do this?
I try to implement multithreading in Lua Api through coroutines using lua_sethook.
here's the code

void LUAHook(lua_State* L, lua_Debug* ar) {
    lua_yield(L, 0);
};
 const char* LUA = R"(
function foo()
for i = 1, 4 do
print(" func foo \n")
end end

function main()
for i = 1, 3 do
print(" func main "..i.."\n")
if j == nil
then
 foo1()
j=1
end
end  end
)";
int foo1(lua_State* L) {
    lua_State* L1 = lua_newthread(L); 
    lua_sethook(L, LUAHook, LUA_MASKLINE, 1);
    lua_getglobal(L1, "foo");
    lua_sethook(L1, LUAHook, LUA_MASKLINE, 1);
    lua_resume(L1, L, 0);


return  0;
};
int main() {
    lua_State* L = luaL_newstate(); luaL_openlibs(L);
    lua_register(L, "foo1", foo1);
    luaL_dostring(L, LUA);
    int ret;
    lua_getglobal(L, "main");// функция lua возобновляется с последней 
    //  прерванной позиции.
    ret = lua_resume(L, NULL, 0);


    return 0;
};

me need to display the following in the console

func main 1
func foo
func main 2
func foo
func main 3
func foo

Index is undefined in Bundle:suspend

Whenever I do a call to rope:listen, the thread crashes because the table index is nil. Specifically, it errors on the line ts[index] = ts[#ts] on line 73. I can't find index defined anywhere, so I'm not sure what was meant here.

Example of the code I'm using:

bundle(function(rope)
    -- do something
    rope:listen("keypress") -- crashes here
    -- do more stuff
end)

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.