diff options
author | Tom Tromey <tromey@adacore.com> | 2024-11-20 11:07:05 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-12-09 13:52:54 -0700 |
commit | 00ce087f83783b31455509401d0b9d3869fcc8be (patch) | |
tree | 865c2812e1691b672e6f1bbc0c47f7dbbbccfc5e /gdb/python | |
parent | d50cf1cea853395da5fcd13c0d116a7332edff26 (diff) | |
download | gdb-00ce087f83783b31455509401d0b9d3869fcc8be.zip gdb-00ce087f83783b31455509401d0b9d3869fcc8be.tar.gz gdb-00ce087f83783b31455509401d0b9d3869fcc8be.tar.bz2 |
Reimplement DAP delayed events
This patch changes how delayed events are implemented in DAP. The new
implementation makes it simpler to add a delayed function call, which
will be needed by the final patch in this series.
Reviewed-by: Kévin Le Gouguec <legouguec@adacore.com>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/server.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py index 8c6d908..ceffefc 100644 --- a/gdb/python/lib/gdb/dap/server.py +++ b/gdb/python/lib/gdb/dap/server.py @@ -124,9 +124,9 @@ class Server: self.in_stream = in_stream self.out_stream = out_stream self.child_stream = child_stream - self.delayed_events_lock = threading.Lock() + self.delayed_fns_lock = threading.Lock() self.defer_stop_events = False - self.delayed_events = [] + self.delayed_fns = [] # This queue accepts JSON objects that are then sent to the # DAP client. Writing is done in a separate thread to avoid # blocking the read loop. @@ -246,13 +246,13 @@ class Server: result = self._handle_command(cmd) self._send_json(result) self._handle_command_finish(cmd) - events = None - with self.delayed_events_lock: - events = self.delayed_events - self.delayed_events = [] + fns = None + with self.delayed_fns_lock: + fns = self.delayed_fns + self.delayed_fns = [] self.defer_stop_events = False - for event, body in events: - self.send_event(event, body) + for fn in fns: + fn() # Got the terminate request. This is handled by the # JSON-writing thread, so that we can ensure that all # responses are flushed to the client before exiting. @@ -264,8 +264,8 @@ class Server: def send_event_later(self, event, body=None): """Send a DAP event back to the client, but only after the current request has completed.""" - with self.delayed_events_lock: - self.delayed_events.append((event, body)) + with self.delayed_fns_lock: + self.delayed_fns.append(lambda: self.send_event(event, body)) @in_gdb_thread def send_event_maybe_later(self, event, body=None): @@ -275,9 +275,9 @@ class Server: the client.""" with self.canceller.lock: if self.canceller.in_flight_dap_thread: - with self.delayed_events_lock: + with self.delayed_fns_lock: if self.defer_stop_events: - self.delayed_events.append((event, body)) + self.delayed_fns.append(lambda: self.send_event(event, body)) return self.send_event(event, body) |