Threaded callback from within plugin
In my plugin I do a callback to a steve function that resets a bunch of joints to a default position. Now I had to experience that _only_ when this is done from within the thread (an extra started one) the joints do not get rotated to the default position all at once, but with a delay.
To make this clearer: 3 joint shall be moved to max-position. In a time chart something like alljoints set-to-max
should be like this (where each x is a timeslices, where the jopint is still rotating):
time ---->
joint0: xxxxxxxx
joint1: xxxxxxxx
joint2: xxxxxxxx
Instead this happens
joint0: xxxxxxxx
joint1: xxxxxxxx
joint2: xxxxxxxx
I can only guess that this happens because of the racing conditions of my plugin thread and the breve simulation thread. I remembered that Jon put some functions into the plugin library for locking the engine:
brEngineLock(instance->engine);
brEngineUnlock(instance->engine);
But these only cause my application to hang in a deadlock. Here is my plugin code which starts its own thread and locks the engine from within it:
void doIt(void* args)
{
brEval returnValue;
brInstance* i = (brInstance*)args;
brEngineLock(i->engine);
brMethodCallByName(i, "reset1", &returnValue);
brEngineUnlock(i->engine);
}
int testResetProxy(brEval args[], brEval* result, void* instance)
{
// start a new windows thread
_beginthread(doIt, 0, instance );
// this outcommented lines would reset the joints perfectly, because it happens in the same thread
// as the simulation runs
// brEval returnValue;
// brMethodCallByName( ((brInstance*)instance), "reset1", &returnValue);
return EC_OK;
}
Does anyone can support a solution?

Odd
Very odd -- I would definitely expect that to work. Any chance you can run this with a debugger and see where the separate threads are stuck?
Are you sure that the second thread is in fact running separate from the first?
- jon
I wish I could debug the
I wish I could debug the thing. But because I am working under Windows and only crosscompiling my plugins I need to run Breve for testing. I am not able to write standalone applications which I could debug.
Despite of that I am absolutely sure that this is a separate thread becaus I use one thread to execute a non-breve-blocking tcp/ip server.