nvtx icon indicating copy to clipboard operation
nvtx copied to clipboard

Drop guard API for ranges

Open adeschamps opened this issue 2 years ago • 1 comments

Would you be interested in accepting a PR that adds a drop guard API for working with ranges? This would be convenient for cases where a function could return in multiple places and matching range_start!()/range_end!() or range_push!()/range_pop!() is tricky. I'm thinking of an API that would allow the following:

fn example() -> Result<()> {
    let _range = nvtx::range!("Hello World!");
    fallible_operation()?
    if some_condition {
        return;
    }
    Ok(())
    // _range goes out of scope and ends the NVTX range
}

If this is something you'd be interested in, I'll open a PR sometime soon.

adeschamps avatar Dec 20 '23 14:12 adeschamps

Yeah, I'd accept this.

nuzzles avatar Dec 20 '23 16:12 nuzzles