class_docstr: Wrapper around the queue that enables writing to the queue in a separate thread, just in
  case a writing process would have to wait too long for a lock on the queue when multiple
  readers pop the items one by one.
class_docstr_tok: ["Wrapper","around","the","queue","that","enables","writing","to","the","queue","in","a","separate","thread",",","just","in","case","a","writing","process","would","have","to","wait","too","long","for","a","lock","on","the","queue","when","multiple","readers","pop","the","items","one","by","one","."]
code: def _dispatch_loop(self):
      try:
          while True:
              with self.pending_cv:
                  while len(self.pending) == 0:
                      self.pending_cv.wait()
                  msgs = list(self.pending)
                  self.pending.clear()
              if any(msg is None for msg in msgs):
                  break
              msgs = self.serialize_msgs(msgs)
              if self.target_queue.put(msgs) is None:
                  break
      finally:
          if self.on_thread_exit is not None:
              self.on_thread_exit()
  
imports: from typing import List, Optional
  import os
  import threading
  from nvidia.dali._multiproc import shared_mem
  from nvidia.dali._multiproc.messages import Structure, ShmMessageDesc
  from nvidia.dali._multiproc.shared_batch import _align_up
label_desc: Use image node_id 2 for calling the Dispatcher obj's underlying member method code with example usage: obj._dispatch_loop() without return types