Commit 10fdeba
committed
refactor(provider): atomic singleton + ScopedProviderOverride
TrustProvider* g_installed_provider was a raw pointer global — no
atomicity, no ownership, no RAII restore. Parallel test runners
and any future multi-worker runtime could tear the pointer while
another thread is mid-install.
Fix:
- Back the singleton with std::atomic<TrustProvider*>.
runtime_provider() does an acquire-load, install_provider_for_
testing() does an acq_rel exchange and now returns the previous
pointer so callers can restore.
- Add ScopedProviderOverride: RAII class that installs on
construction and restores the prior pointer on destruction.
Non-copyable, non-movable; preferred over manual install calls
because tests become exception-safe and composable.
Backwards-compat: tests that still call install_provider_for_
testing() directly work unchanged (they just ignore the return
value). ScopedProviderOverride becomes the recommended pattern for
any new call site.
Tests 1124/1124 green.1 parent 4dd0c30 commit 10fdeba
2 files changed
Lines changed: 40 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
281 | 283 | | |
282 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
283 | 311 | | |
284 | 312 | | |
285 | 313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
226 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
227 | 231 | | |
228 | 232 | | |
229 | 233 | | |
| |||
526 | 530 | | |
527 | 531 | | |
528 | 532 | | |
529 | | - | |
| 533 | + | |
| 534 | + | |
530 | 535 | | |
531 | 536 | | |
532 | 537 | | |
533 | | - | |
534 | | - | |
| 538 | + | |
| 539 | + | |
535 | 540 | | |
536 | 541 | | |
537 | 542 | | |
0 commit comments