lawrence_danna marked an inline comment as done.
lawrence_danna added inline comments.


================
Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1057
+
+  // global is protected by the GIL
+  static PythonScript read_exception(read_exception_script, "read_exception");
----------------
labath wrote:
> I just realized I don't actually know what this means. Is it that the object 
> takes the GIL internally? Or that one must have the GIL taken before he 
> starts to interact with it? Maybe it'd be better to clarify this in the class 
> description and just delete these comments.
Almost everything in PythonDataObjects requires you to call it with the GIL 
already locked.  The only things that don't are the File methods because 
they're called by things that don't know anything about python.

Normally when I need to do something like this I would use dispatch_once, or 
whatever the LLVM version of that is, so you avoid static initializers, but 
also initialize the thing in a thread-safe way.

But in this case we already know that this function can only be called by a 
thread that has the GIL, so it's safe to just initialize a global variable 
without further synchronization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69214/new/

https://reviews.llvm.org/D69214



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to