Discussion:
[Swig-user] SWIG C# thread safety
Jeremy Cowles
2017-06-11 02:24:42 UTC
Permalink
Are Swig bindings thread safe?

Reading the docs, it's a bit vague, but it sounds like the only concerns
are with the C++ run-time.

--
Jeremy
Jeremy Cowles
2017-06-11 04:29:01 UTC
Permalink
FYI, I'm asking because it looks like thread-safe types in C++ are causing
memory errors when passed between threads in C# -- specifically if the
object goes out of scope; long-lived objects seem fine.

Also, yes, all libs are compiled with /MD and the types are built to be
thread safe, explicitly.
Post by Jeremy Cowles
Are Swig bindings thread safe?
Reading the docs, it's a bit vague, but it sounds like the only concerns
are with the C++ run-time.
--
Jeremy
William S Fulton
2017-07-01 14:22:42 UTC
Permalink
There are different levels of thread-safety, but the generated code aims to
not make the C++ layer any less thread-safe. You may have more of a garbage
collection and lifetime issue. If as far as the managed world goes, an
object has gone out of scope, it will be gc'd even though it may still be
in use in the C++ world. Also make sure your destructors are fully
thread-safe.

William
Post by Jeremy Cowles
FYI, I'm asking because it looks like thread-safe types in C++ are causing
memory errors when passed between threads in C# -- specifically if the
object goes out of scope; long-lived objects seem fine.
Also, yes, all libs are compiled with /MD and the types are built to be
thread safe, explicitly.
Post by Jeremy Cowles
Are Swig bindings thread safe?
Reading the docs, it's a bit vague, but it sounds like the only concerns
are with the C++ run-time.
--
Jeremy
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...