class_docstr: A class representing an EGL context. In short, EGL allows us to render OpenGL con-
  tent in a headless mode, that is without an actual display to render to. This capa-
  bility enables MeshRasterizerOpenGL to render on the GPU and then transfer the re-
  sults to PyTorch3D.
class_docstr_tok: ["A","class","representing","an","EGL","context",".","In","short",",","EGL","allows","us","to","render","OpenGL","con-","tent","in","a","headless","mode",",","that","is","without","an","actual","display","to","render","to",".","This","capa-","bility","enables","MeshRasterizerOpenGL","to","render","on","the","GPU","and","then","transfer","the","re-","sults","to","PyTorch3D","."]
docstr: A context manager used to make sure a given EGL context is only current in
  a single thread at a single time. It is recommended to ALWAYS use EGL within
  a `with context.active_and_locked():` context.
  
  Throws:
      EGLError when the context cannot be made current or make non-current.
docstr_tok: ["A","context","manager","used","to","make","sure","a","given","EGL","context","is","only","current","in","a","single","thread","at","a","single","time",".","It","is","recommended","to","ALWAYS","use","EGL","within","a","`","with","context.active_and_locked","(",")",":","`","context",".","Throws",":","EGLError","when","the","context","can","not","be","made","current","or","make","non-current","."]
code: def active_and_locked(self):
      """
      A context manager used to make sure a given EGL context is only current in
      a single thread at a single time. It is recommended to ALWAYS use EGL within
      a `with context.active_and_locked():` context.
  
      Throws:
          EGLError when the context cannot be made current or make non-current.
      """
      self.lock.acquire()
      egl.eglMakeCurrent(
          self.dpy, self.surface, self.surface, self.context
      )
      try:
          yield
      finally:
          egl.eglMakeCurrent(
              self.dpy,
              egl.EGL_NO_SURFACE,
              egl.EGL_NO_SURFACE,
              egl.EGL_NO_CONTEXT,
          )
          self.lock.release()
  
imports: import contextlib
  import ctypes
  import os
  import threading
  from typing import Any, Dict
  import OpenGL.EGL
  import pycuda.driver
  from OpenGL._opaque import opaque_pointer_cls
  from OpenGL.raw.EGL._errors import EGLError
label_desc: Use image node_id 2 for calling the EGLContext obj's underlying member method code with example usage: obj.active_and_locked() without return types