This seems a reasonable goal, but is it incompatible to serialize access
to the C++ objects with H5_HAVE_THREADSAFE turned on?  The point you make
about global variables is valid as well, but there are two problems, and
both need solving:


1. HDF5 C Library not stepping on its own feet.
2. not having your program garble things up via the non-thread-safe
interface.

If only one or the other is managing things, it is more efficient, but the
performance hit can't be that huge.

The other alternative is to write your own C++ classes to manage access to
the C API. The HDF5 C++ bindings are a pretty thin layer over the C
bindings. Depending on the complexity of your application this might not
be a significant additional coding effort.

I used the C++ bindings in the ITK toolkit, and I still had to understand
the underlying library interface to do things; if I had to do it all over
again I'd go directly with the C API, because it gives one finer-grained
control, and also avoids dealing with the slight quirks of the C++ API.
Using the C++ API did seem to add some second order head-scratching to the
project.

On 6/27/11 11:49 AM, "Matthew Chambers" <[email protected]> wrote:

>Due to the C++ bindings not being thread-safe, I was hoping to turn off
>thread-safety in the C core
>and handle synchronization in my code. This turned out to be impossible
>because the HDF5 core uses
>global, non-thread-specific data structures when H5_HAVE_THREADSAFE is
>undefined. There does not
>appear to be a way to turn off internal synchronization while keeping
>thread or instance specific
>data structures. That would be useful. SQLite has good semantics for
>thread safety:
>
>http://www.sqlite.org/compile.html#threadsafe
>> This option controls whether or not code is included in SQLite to
>>enable it to operate safely in
>> a multithreaded environment. The default is SQLITE_THREADSAFE=1 which
>>is safe for use in a
>> multithreaded environment. When compiled with SQLITE_THREADSAFE=0 all
>>mutexing code is omitted
>> and it is unsafe to use SQLite in a multithreaded program. When
>>compiled with
>> SQLITE_THREADSAFE=2, SQLite can be used in a multithreaded program so
>>long as no two threads
>> attempt to use the same database connection at the same time.
>
>At the very least it would be useful if the documentation specifies that
>H5_HAVE_THREADSAFE controls
>both the use of global data structures and synchronization. I had to dig
>into the code to understand it.
>
>Thanks,
>-Matt
>
>_______________________________________________
>Hdf-forum is for HDF software users discussion.
>[email protected]
>http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the 
Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and 
may be legally privileged.  If you are not the intended recipient, you are 
hereby notified that any retention, dissemination, distribution, or copying of 
this communication is strictly prohibited.  Please reply to the sender that you 
have received the message in error, then delete it.  Thank you.
________________________________

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to