dict access and threading

Dec 12, 2012 at 5:13pm

dict access and threading

Hi,

I’d like to read/write from/to a registered dictionary, but I have some trouble understanding how dictionary accessing is managed in a multi-threaded scenario. So, basically there are two separate questions here:

(1) Should dict-related function calls always be deferred to the main thread (and can developers rely safely on this assumption, ie. are all dict-related standard objects implemented with this taken into consideration)?

The following question, I guess, makes only sense if the answer to (1) is ‘no’:

(2) When I make a call to dictobj_findregistered_retain(), is the dict locked against further modifications as long as I don’t make a call to dictobj_release(), or should I always call dictobj_findregistered_clone() in the case when I need to read a lot from the dict?

More generally: if the answer to (1) is ‘no’, then how are we supposed to properly read and write dictionaries?

Thanks,
Ádám

#65643
Jan 7, 2013 at 1:19pm

Hi Ádám,

At this point in time, dictionary access does not have any thread-safety baked-in on which you should rely. Most operations in Max assume operation on the main thread, so you would do best to also have your dictionary access occur on the main thread.

Cheers,
Tim

#236450
Jan 7, 2013 at 2:40pm

Hi Tim,

thanks for the clarification, in that case I’ll defer everything to the main thread.

Cheers,
Ádám

#236451

You must be logged in to reply to this topic.