From: Robert Ramey (ramey_at_[hidden])
Date: 2008-08-29 02:17:43
Kirit Sælensminde wrote:
> We have a similar requirement for a static library of factories for
> serialisation (in our case for O/RM, but the principle is the same)
> and when I put all of this together it seemed that the only way to do it
> reliably was to use a read/write mutex around accesses to the static
> data. This way most of the reads can still happen in parallel with the
> very occasional writes taking exclusive control of the structure.
I looked into this very carefully. I could find no way to do
it without a very large performance penalty. It would also
require inclusion of the boost threading library - which might
conflict with other libraries. This price would be paid
by all users - unless there was a way to turn it off - another
complication. It just wasn't worth it.
I take great pains to avoid adding so many disjoint features to the library
that it becomes too bloated and too hard to understand.
The current system requires that DLLS not be loaded/unloaded
while an archive is open. I presumed that such a restriction
would be easy to live by. If for some case it's not, you
could make a semaphore which you would acquire for the
actions dll load/dll unload/archive load/save. Of course
you'll have to worry about deadlocks, but you've probably
already taking steps to avoid that.
It would be possible to make an archive adaptor for which
could be added to any archive (through multiple derivation)
which would automate the semaphore aquisition. If all
your code used these enhanced archives (and you dll
loading/unloading was similarly enhanced), you could
"fire and forget" with almost no performance penalty
as the semaphores would be accessed only once
per archve open/close rather than for every access.
If this suggestion isn't good enough for you, I'm sorry, its
the best I can do.