dictionary_read behavior ?

Jan 26, 2013 at 8:07am

dictionary_read behavior ?

Hi,

1. Is the “dictionary_read” function always return a new allocated dictionary, or is it possible to pass a pointer to a valid dictionary to reuse it ?

2. Is “dictionary_read” / “dictionary_write” globally lock something ?

(max 5 SDK / max 6 SDK) ?

#66232
Feb 7, 2013 at 10:08pm

Yes, dictionary_read() always returns newly alloc’d memory.

It should not be locking anything globally. Are you seeing some sort of contention that leads you to believe that it is locking?

#238405
Feb 8, 2013 at 7:43am

HI,

“Are you seeing some sort of contention that leads you to believe that it is locking?”

Nothing precise ; but sometimes when i write a t_dictionary to disk i have a small lag (only the first time the function is used after the computer is turn on) ; I hate those kind of bug ; I expected that performing in the main thread would avoid to stall the timer thread but surely i have a contention somewhere (with the GUI for instance) that i can not find.

I must admit that it’s hard to understand locks implied with object_free and such. Anyway i gave up to understand what’s going on under the hood and decided to rewrite it using a STL map ;-)

Thanks for reply.

#238406
Feb 11, 2013 at 2:06pm

Sure, that’s reasonable. Just be aware the std::map will probably not perform as well as t_dictionary for key lookups.

If you wanted to implement something like what t_dictionary does you would need to create your own class that includes both a std::unordered_map (for fast lookups) and a std::list (for sorting).

Cheers

#238407
Feb 11, 2013 at 2:42pm

Hi,

For now, I have not decided the structure i’ll use. I don’t know if i will go with a handy Python-like dictionary or with a map or even an hash table. I’ll wait to explore the Boost API before to do any choice. Anyway thanks for advices.

#238408

You must be logged in to reply to this topic.