The caller must be holding the mutex_.
| 284 | |
| 285 | // The caller must be holding the mutex_. |
| 286 | void get_reference() { |
| 287 | modify_atomic_state([](AtomicState& cur_state) { |
| 288 | // Check whether the reference count would wrap. There is no use case that |
| 289 | // currently needs to exceed 65k concurrent references, and this is likely |
| 290 | // to be a bug in the caller's code. For now, this asserts, but there may be |
| 291 | // a better behavior if needed. |
| 292 | CHECK_LT(cur_state.ref_count, std::numeric_limits<uint16_t>::max()); |
| 293 | ++cur_state.ref_count; |
| 294 | }); |
| 295 | } |
| 296 | }; |
| 297 | |
| 298 | struct LIRSThreadState { |