feat(rust-ocr): count async offloads in gil accounting

This commit is contained in:
Ishaan Jaffer 2026-06-23 14:16:19 -07:00
parent c4de80c5c9
commit e3b6761b5d
No known key found for this signature in database

View file

@ -26,6 +26,15 @@ where
py.allow_threads(f)
}
/// Record an off-GIL offload without wrapping a closure.
///
/// The async `aocr` path hands work to the Tokio runtime, which runs without the
/// GIL by construction, so there is no `allow_threads` closure to wrap — this
/// keeps the release count accurate across both entry points.
pub fn note_offload() {
GIL_RELEASES.fetch_add(1, Ordering::Relaxed);
}
/// Total GIL releases performed by the bridge so far.
pub fn release_count() -> u64 {
GIL_RELEASES.load(Ordering::Relaxed)