[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Thread in library which call Lua function
- From: "Robert G. Jakabosky" <bobby@...>
- Date: Sat, 16 Apr 2011 08:15:54 -0700
On Saturday 16, jseb wrote:
>
> I tried this, because i use a method similar to my first attempt with
> freeglut.
> Freeglut is initialised, and define its redraw callback like a calling
> to Lua. So the Freeglut loop is like this:
>
> (sleep n ms) -> call redraw -> call lua function -> rearm freeglut timer
> ^ |
>
> |_________________________________________________________|
>
> I've got Freeglut sources, and searched for threads inside. No threads,
> as far i know. I don't know how Freeglut runs in parallel of my other
> code then (as he's sleeping most of time, it should block the other
> parts of my program if it wasn't threaded, but it doesn't).
Freeglut might be using alarm(2) and a signal handler on SIGALRM for the
timer.
> So that's why i can store a Lua's context and its callback redraw
> function when using Freeglut. I was wrong trying to mimic this mechanism
> with threads.
Signals have the same thread-safety issues that threads do. You can't safely
call a Lua function from a signal handler.
--
Robert G. Jakabosky