Spinnaker::System::GetInstance() question about singleton status and thread safety
I have two questions.
First, in the documentation it is mentioned the system instance is a singleton. However, I can call:
Spinnaker::SystemPtr system1 = Spinnaker::System::GetInstance();
Spinnaker::SystemPtr system2 = Spinnaker::System::GetInstance();
And interact with both system pointers. I can even release() system1 and system2 will still work. So to me it doesn't appear to be a singleton. I was expecting either an error to be returned or both pointers to point to the same thing.
It's also not clear from the examples because they all call GetInstance() once at the beginning of main(). But in the problem I'm working on it would be useful for a Camera class to have access to the system pointer and I'm wondering if I can create a system pointer for each camera object via GetInstance() or if I need to create one system pointer and pass it to both camera objects. Hopefully that makes sense.
My next question is is "Spinnaker::SystemPtr" thread safe? If I have two camera objects with methods running in two different threads, if they both call methods to systemptr, is that thread safe? Would it make a difference if each camera had its own SystemPtr via GetInstance() or if its the same SystemPtr via one call to GetInstance() and copies of the pointers passed in?
Thanks,
-Justin
-
Hello Justin,
We would require to investigate this further and get back to you. To ensure we are on the same page, could you share a sample code that would help us replicate exactly the same singleton behaviour?
Thanks,
Ifeanyi.
0
Please sign in to leave a comment.
Comments
1 comment