synchronized<T> method

T synchronized<T>(
  1. T action()
)

Executes a function within a synchronized block.

This ensures thread-safe access to the registry's internal state. In Dart, isolates are separate, but within a single isolate, we ensure operations are atomic by using a lock object.

Implementation

T synchronized<T>(T Function() action) {
  // In Dart's single-threaded model within an isolate, we don't need
  // complex locking, but we maintain this pattern for future-proofing
  // and to make the thread-safety contract explicit.
  return action();
}