foo_new( ) method and thread…

Jun 28, 2012 at 2:42pm

foo_new( ) method and thread…

Hello,

Do the foo_new( ) method (for a CLASS_BOX object) can be multithreaded, or do instantiation occurs in a unique thread ? Do i have to protect a counter like below ?

static long toto = 1;

void *foo_new(...)
{
    x->toto = toto++;
}

The instantiation seems always in the main thread.

Is there any situation where it happens in the timer thread ?
I mean it can with object_new_typed call from an external ; but is possible in patching scenario ?

#41741
Jun 28, 2012 at 6:45pm

Hi,

not being a Cycling-guy I can’t tell a 100% sure answer, but if I were you, I would create a test object with a call to systhread_ismainthread in the object instantiation routine and store the result (or maybe simply post it to the Max window). Then I would create a couple of hundreds/thousands of the test external and see what happens. To make it even nicer, you could try to trigger the script from the scheduler thread and see if that matters or not. My guess is that the objects will instantiate always in the main thread, but I didn’t test this myself.

Hope this helps,
Ádám

#148965
Jun 28, 2012 at 6:46pm

Oh, and don’t forget to check whether Overdrive on/off makes any difference.

#148966
Jun 28, 2012 at 7:34pm

As Siska correctly deducts, all object creation and destruction occurs on the main thread.

Cheers,
Tim

#148967
Jun 29, 2012 at 4:55am

Hello,

@Siska Ádám : that’s exactly what i did and the instantiation occurs always in main thread even with timer scheduled script.

@Timothy Place : thank you very much for the confirmation.

#148968

You must be logged in to reply to this topic.