Game Development Community

Debug Assertion: "ProcessEvent is not reentrant"?

by Rodrigo · in Torque Game Engine · 08/01/2005 (1:27 pm) · 1 replies

In my code, I created a special event FooEvent and try calling Game->postEvent(FooEvent) to handle it like other Torque events. However I'm getting the fatal assertion "ProcessEvent is not reentrant". I haven't been able to find much in the docs or forums on what this means exactly.

The assert is caused in GameInterface::processEvent(). The engine code has
sReentrantCount++;
at the beginning and
sReentrantCount--;
at the end of the function. Right after
sReentrantCount++;
Torque calls
AssertFatal(sReentrantCount == 1, "Error! ProcessEvent is NOT reentrant.");
to make sure that sReentrantCount == 1.

If I put in a break when debugging, I notice that sReentrantCount == 2 at some point which is causing the Assert. I guess this means that somehow, when I call, postEvent(), ::processEvent() is already processing some other event?

Anyone know anything about the proper way to call postEvent() to make sure this doesn't happen? Is there a safer way? I think this is somehow related to multithreading. My Game->postEvent(FooEvent) is happening on another thread.

#1
08/01/2005 (5:01 pm)
Torque, especially 1.3, is NOT multithread safe. The upcoming 1.4 release will be multithread safer, though using it in ways not anticipated will break it.

Put a mutex on it. :)