# Cache: fix data race with is_problematic_timestamp · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/fdbb329d1009b4c7b23552e65c0344e3ce52b459)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: fdbb329d1009b4c7b23552e65c0344e3ce52b459

Requested commit: fdbb329d1009b4c7b23552e65c0344e3ce52b459

Commit: fdbb329d1009b4c7b23552e65c0344e3ce52b459

Tree: ba83854a4725344ffb9132589ca577b2f947a439

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Cache: fix data race with is_problematic_timestamp

Previously `recent_problematic_timestamp` was unprotected and accessed
potentially with multiple worker threads simultaneously.

This commit protects it with atomics and also introduces a flag to
prevent multiple timestamp checks from within the same call to hit().

Unfortunately the compiler-rt function __sync_val_compare_and_swap_16 is
not yet implemented, so I will have to take a different strategy in a
follow-up commit.

```

## Parents

- [4da83feccb4b0e59afdcce9796b08cc4fc8346ae](https://git.cafe/gitcafe/zig/commit/4da83feccb4b0e59afdcce9796b08cc4fc8346ae?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/fdbb329d1009b4c7b23552e65c0344e3ce52b459?format=markdown)
