Uniquely identifying sv class instance from whose member function a dpi call was made

I have a dpi call happening in a member function of a sv class. In the dpi function, I wish to uniquely identify the instance from whose member function the dpi call was made. I cannot use svGetScope() as it returns the scope of the function’s declaration site, not call site and it happens the dpi functions are to be declared outside the class. So, if I use svGetScope() everytime it returns the same scope. Is there any other way.
Thank u

In reply to Aman551:

Class instances do not have scopes, only a handle which is meaningless outside SystemVerilog. You could create an array of class handles which have a unique index that you could pass through as an argument to the DPI call.

In reply to dave_59:

Thank u dave_59. Currently I am doing the same i.e. I have a static longint unsigned variable in the class that gets incremented in the constructor of the class. I am passing this to dpi. My other question is that (coming from cpp background), should I have some protection (mutex) while incrementing this static variable in the constructor of the class.

In reply to Aman551:

You can’t put a mutex or any construct that might block in a constructor. Although ++/-- are not defined as atomic operators, I doubt you will run into an implementation that would not treat them that way. You could wrap a mutex around the constructor if you need to be totally strict with the LRM.