Daniel Turing a écrit :
On Wed, 2009-01-28 at 20:52 +0100, Daniel Turing wrote:
i'll post again if i find a reproducible, small sample for my
problems.
So, i've found the cause of my problems. It's not quite easy to
reproduce but relatively easy to explain:
I run just two threads, let's call them "Main" and "Worker". Main is a
usual Xinfinity program with its usual OpenGL calls. Worker is a
background resource loader/renderer, that renders into memory buffers
(not directly to GL textures).
What actually happens is that the worker thread needs to allocate some
memory, and, in the process, triggers boehm's GC. This finds some stuff
to delete that is not safe to delete from that thread. GL is not fully
threadsafe (please dont ask me about the details ;) Suffice to say there
is no simple way to keep a lock for the destructor (it already locks
itself per older discussion on a similar topic).
Now, i think the best solution would be to temporarily disable garbage
collection when this thread actually does its work. GC_enable/GC_disable
are not represented in the neko API, but i guess they could be. What do
you think about that, Nicolas?
That's quite a hack and would not work in case another thread is running
for any other reason. I guess that it's needed at this point to allow
explicit deallocation of your OGL structures (and use these when writing
MT programs).
Another solution might be, when the finalizer is called from another
thread, to queue the free operation for later execution from the main
thread. All these operations would be triggered by explicitly calling
.OGLGarbage() on a regular basis for instance.
Best,
Nicolas
--
Neko : One VM to run them all
(http://nekovm.org)