Forums > Dev

dict access and threading

December 12, 2012 | 5:13 pm

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


January 7, 2013 | 1:19 pm

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


January 7, 2013 | 2:40 pm

Hi Tim,

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

Cheers,
Ádám


Viewing 3 posts - 1 through 3 (of 3 total)