[all-commits] [llvm/llvm-project] f01a32: [lldb] Add an Alarm class for coalescing progress ...

Jonas Devlieghere via All-commits all-commits at lists.llvm.org
Fri Mar 15 09:36:00 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f01a32f5c58b199edf7cd1492a20578453852f0e
      https://github.com/llvm/llvm-project/commit/f01a32f5c58b199edf7cd1492a20578453852f0e
  Author: Jonas Devlieghere <jonas at devlieghere.com>
  Date:   2024-03-15 (Fri, 15 Mar 2024)

  Changed paths:
    A lldb/include/lldb/Host/Alarm.h
    M lldb/source/Host/CMakeLists.txt
    A lldb/source/Host/common/Alarm.cpp
    A lldb/unittests/Host/AlarmTest.cpp
    M lldb/unittests/Host/CMakeLists.txt

  Log Message:
  -----------
  [lldb] Add an Alarm class for coalescing progress reports (#85329)

The commit introduces a new, generic, Alarm class. The class lets you to
schedule functions (callbacks) that will execute after a predefined
timeout. Once scheduled, you can cancel and reset a callback, given the
timeout hasn't expired yet.

The alarm class worker thread that sleeps until the next timeout
expires. When the thread wakes up, it checks for all the callbacks that
have expired and calls them in order. Because the callback is called
from the worker thread, the only guarantee is that a callback is called
no sooner than the timeout. A long running callback could potentially
block the worker threads and delay other callbacks from getting called.

I intentionally kept the implementation as simple as possible while
addressing the needs for the use case of coalescing progress events as
discussed in [1]. If we want to rely on this somewhere else, we can
reassess whether we need to address this class' limitations.

[1] https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717/



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list