Multi threading
Ohmoc is not multithread safe. An Ohmoc instance must always be used from within the same thread, or with locks around it to prevent race conditions.
However there are alternatives you can use. Since the file is locked when a thread is actively reading from it, having two Ohmoc instances sharing the file path is safe.
Alternatively, you can use a task queue and callbacks. Luckily, OhmocAsync provides this functionality out of the box.
Allow Duplicates
When an Ohmoc object is created, it can decide to allowDuplicates
or not.
When the flag is off, the instance is statically stored and Ohmoc will return this instance when the class method instance
is called from the same thread. Attempting to create a second Ohmoc from the same thread using allowDuplicates
will throw an exception.
When the flag is on, the instance is not registered and just returned.
The nice part of having this flag disabled is to get a nicer syntax when querying for objects. OOCModel provides shortcuts that use this global variable to simplify the code.
Updated less than a minute ago