class_docstr: Accumulates a session's outgoing ForwardMsgs.
  
  Each AppSession adds messages to its queue, and the Server periodically
  flushes all session queues and delivers their messages to the appropriate
  clients.
  
  ForwardMsgQueue is not thread-safe - a queue should only be used from
  a single thread.
class_docstr_tok: ["Accumulates","a","session","'s","outgoing","ForwardMsgs",".","Each","AppSession","adds","messages","to","its","queue",",","and","the","Server","periodically","flushes","all","session","queues","and","delivers","their","messages","to","the","appropriate","clients",".","ForwardMsgQueue","is","not","thread-safe","-","a","queue","should","only","be","used","from","a","single","thread","."]
docstr: Add message into queue, possibly composing it with another message.
docstr_tok: ["Add","message","into","queue",",","possibly","composing","it","with","another","message","."]
code: def enqueue(self, msg: ForwardMsg) -> None:
      """Add message into queue, possibly composing it with another message."""
      if not _is_composable_message(msg):
          self._queue.append(msg)
          return
  
      # If there's a Delta message with the same delta_path already in
      # the queue - meaning that it refers to the same location in
      # the app - we attempt to combine this new Delta into the old
      # one. This is an optimization that prevents redundant Deltas
      # from being sent to the frontend.
      delta_key = tuple(msg.metadata.delta_path)
      if delta_key in self._delta_index_map:
          index = self._delta_index_map[delta_key]
          old_msg = self._queue[index]
          composed_delta = _maybe_compose_deltas(
              old_msg.delta, msg.delta
          )
          if composed_delta is not None:
              new_msg = ForwardMsg()
              new_msg.delta.CopyFrom(composed_delta)
              new_msg.metadata.CopyFrom(msg.metadata)
              self._queue[index] = new_msg
              return
  
      # No composition occurred. Append this message to the queue, and
      # store its index for potential future composition.
      self._delta_index_map[delta_key] = len(self._queue)
      self._queue.append(msg)
  
file_path: streamlit/lib/streamlit/runtime/forward_msg_queue.py
imports: from typing import Any, Dict, List, Optional, Tuple
  from streamlit.logger import get_logger
  from streamlit.proto.Delta_pb2 import Delta
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
label_desc: Use image node_id 4 for calling the ForwardMsgQueue obj's underlying member method code with example usage: obj.enqueue(msg) without return types