2006/12/24, John Labenski <[EMAIL PROTECTED]>:
> What you're suggesting is not normal, it's better to have the system's
> native mainloop control program flow rather than implementing your own
> which will most likely be far less efficient. In any case you should
> be able to do it using wxApp::Pending and wxApp::Dispatch.

wxApp::Pending+wxApp::Dispatch seems to be exactly what I need.

I don't know what your definition of normal is, but my question seems
perfectly normal to me. What I want to achieve is to have several Lua
frameworks working together in a single thread (because Lua is not
thread safe). Each of my frameworks need to be updated several times a
second, but I can't give application main loop control to any of
these, so I need to make them cooperate.

Example :

void F1::MainLoop()
{
    bool quit;
    Message message;
    while (message = F1::GetMessage_Blocking())
    {
        F1::ProcessMessage(message);
    }
}

void F2::MainLoop()
{
    bool quit;
    do
    {
        F2::Render();
        quit = F2::ProcessInput();
    } while (!quit);
}

void F3::MainLoop()
{
    bool quit;
    do
    {
        F3::Update();
        if (F3::LastError())
            quit = true;
    } while (!quit);
}

void InterleavedMainLoop()
{
    bool quit = false;
    Message message;
    while (true)
    {
        // Update framework F1
        while (F1::IsMessagePresent())
        {
            message = F1::GetMessage_NonBlocking();
            if (message)
                F1::ProcessMessage();
            else
                quit = true;
        }
        if (quit) break;

        // Update framework F2
        F2::Render();
        quit = F2::ProcessInput();
        if (quit) break;

        // Update framework F3
        F3::Update();
        if (F3::LastError())
            quit = true;
        if (quit) break;

        // Main application control refresh rate
        usleep(10000);
    }
}

Replace F1 with wxLua, F2 with my OpenGL renderer and F3 with john
doe's network framework if that makes things clearer. The basic idea
is that an extension module should not take control of the
application. There are a lot of multi-threaded solution to this kind
of problem, but in some context a full thread control is a big
requirement for an extension module.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to