[Feature] Thread-safe plugin implementation
1tnguyen opened this issue · 1 comments
There is a need to use XACC's plugins in a thread-safe manner (multi-threading).
e.g., https://github.com/eclipse/xacc/pull/455/files
Using mutex
to guard member functions may not be sufficient since service implementations may have internal states (e.g., set by initialize()
).
Hence, to enable safe multi-threading of XACC, we should make all services cloneable, i.e., the service registry returns independent instances of the plugin when requested.
For example, one potential systematic way to do this is to make Identifiable
(all services are derived from this) also cloneable.
@tnguyen-ornl thank you for opening this issue!
Just for future references, the pull request above makes NLOptimizer
cloneable. Similarly, this pull request for QCOR (https://github.com/ORNL-QCI/qcor/pull/157) makes VQEObjective
cloneable.
And I agree with you that we'll need to somehow make all services cloneable.