class_docstr: The main top-level class that you instantiate once, or once per module.
  
  Example usage:
  
      ffi = FFI()
      ffi.cdef("""
          int printf(const char *, ...);
      """)
  
      C = ffi.dlopen(None)   # standard library
      -or-
      C = ffi.verify()  # use a C compiler: verify the decl above is right
  
      C.printf("hello, %s!\n", ffi.new("char[]", "world"))
class_docstr_tok: ["The","main","top-level","class","that","you","instantiate","once",",","or","once","per","module",".","Example","usage",":","ffi","=","FFI","(",")","ffi.cdef","(","``","''","''","int","printf","(","const","char","*",",","...",")",";","``","''","''",")","C","=","ffi.dlopen","(","None",")","#","standard","library","-or-","C","=","ffi.verify","(",")","#","use","a","C","compiler",":","verify","the","decl","above","is","right","C.printf","(","``","hello",",","%","s","!","\\n","''",",","ffi.new","(","``","char","[","]","''",",","``","world","''",")",")"]
code: def init_once(self, func, tag):
      # Read _init_once_cache[tag], which is either (False, lock) if
      # we're calling the function now in some thread, or (True, result).
      # Don't call setdefault() in most cases, to avoid allocating and
      # immediately freeing a lock; but still use setdefaut() to avoid
      # races.
      try:
          x = self._init_once_cache[tag]
      except KeyError:
          x = self._init_once_cache.setdefault(
              tag, (False, allocate_lock())
          )
      # Common case: we got (True, result), so we return the result.
      if x[0]:
          return x[1]
      # Else, it's a lock.  Acquire it to serialize the following tests.
      with x[1]:
          # Read again from _init_once_cache the current status.
          x = self._init_once_cache[tag]
          if x[0]:
              return x[1]
          # Call the function and store the result back.
          result = func()
          self._init_once_cache[tag] = (True, result)
      return result
  
imports: import sys, types
  from .lock import allocate_lock
  from .error import CDefError
  from .None import model
label_desc: Use image node_id 44 for calling the FFI obj's underlying member method code with example usage: obj.init_once(func, tag) and returns: result, x, x