SIGN IN SIGN UP

filesystem: refactor win32 watcher_impl to use absl mutex and fix buffer alignment (#46655)

Additional Description:
Refactors the Win32 filesystem watcher (`WatcherImpl`):
- Replaces `<concurrent_queue.h>` (`concurrency::concurrent_queue`) with
a thread-safe `ThreadSafeQueue` using `absl::Mutex`. This eliminates
duplicate symbol link conflicts between `libc++` and MSVC
`libconcrt.lib`.
- Changes `DirectoryWatch` buffer type from `std::vector<uint8_t>` to
`std::vector<DWORD>` ensuring 4-byte DWORD alignment required by
`ReadDirectoryChangesW` and `FILE_NOTIFY_INFORMATION`.
- Synchronizes access to `DirectoryWatch::watches_` with an
`absl::Mutex`.
- Adds `callAndLogOnError` with exception handling and rate-limited
logging.
- Updates `watcher_impl_test.cc` to ensure file handles are cleanly
closed before read events and flushes.

Risk Level: medium (Win32 filesystem watcher refactor)
Testing: `bazel test //test/common/filesystem:watcher_impl_test`
Docs Changes: n/a
Release Notes: Included under bug_fixes for Win32 watcher
Platform Specific Features: Windows

---------

Signed-off-by: Jonathan Wu <jtwu@google.com>
J
Jonathan Wu committed
7ab45c90e10a991c979b34c8d76250975df5cb10
Parent: 9a1cf7c
Committed by GitHub <noreply@github.com> on 9/3/2026, 8:07:13 PM