Skip to content

2.0.0

Latest

Choose a tag to compare

@LK-Simon LK-Simon released this 13 Aug 18:55

Adopt owning Observer handles and reduce retained PrecisionThread storage

Problem

ESPressio-Threads exposes ESPressio-Observable registration handles through raw pointer return types:

  • Thread::RegisterThreadObserver()
  • PrecisionThread::RegisterIterationObserver()

This inherits the previous raw-handle leak and ambiguous ownership risks.

Additionally, changing or disabling the PrecisionThread sampling window clears its sample deque but does not guarantee that the deque releases its retained internal storage.

The Thread infrastructure also uses deliberately process-lifetime FreeRTOS resources, but this behavior is not documented clearly and may be mistaken for recurring application leaks.

Proposed changes

  • Update Thread Observer registration APIs to return Observable::ObserverHandlePtr.

  • Adopt ESPressio-Observable 3.0.0 or later.

  • Update all README examples and bundled Arduino examples to retain Observer handles using RAII smart pointers.

  • Release the PrecisionThread sample deque’s retained storage when SetIterationSampleCount() changes the sampling window.

  • Ensure setting the sample count to zero both disables sampling and releases retained sample storage.

  • Clearly document that:

    • ThreadManager
    • ThreadTerminationDispatcher
    • ThreadGarbageCollector

    are process-lifetime FreeRTOS infrastructure.

  • Explain that their queues, tasks, semaphores, and synchronization resources are fixed infrastructure allocations rather than per-Thread leaks.

  • Retain the process-lifetime ThreadManager instance deliberately, avoiding unsafe static-destruction ordering with global Thread objects and stopped FreeRTOS infrastructure.

Version impact

The Thread and PrecisionThread Observer registration return types change from raw pointers to owning smart pointers.

Target version: 2.0.0

Dependency changes

  • ESPressio-Observable >=3.0.0
  • ESPressio-Timing remains >=1.1.0

Acceptance criteria

  • Lifecycle and iteration Observer handles use RAII ownership.
  • Existing raw owning-handle usage is removed from documentation and examples.
  • Reconfiguring or disabling sampling releases retained deque storage.
  • Process-lifetime Thread infrastructure is explicitly documented.
  • ESP32 PlatformIO compilation succeeds against ESPressio-Observable 3.0.0.