serialize method
Serialize a read-modify-write against everything else touching the same logical path — captures against each other, and captures against the sync engine's compare-and-swap.
Implementation
@override
Future<void> serialize(String logicalPath, Future<void> Function() op) {
final prev = _chains[logicalPath] ?? Future<void>.value();
final next = prev.then((_) => op()).catchError((Object e) {
debugPrint('[EmbedCache] op failed for $logicalPath: $e');
});
_chains[logicalPath] = next;
next.whenComplete(() {
if (identical(_chains[logicalPath], next)) _chains.remove(logicalPath);
});
return next;
}