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
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.
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.
Associate Kyle Carter
Put a mutex on it. :)