Way to have assertion whether something is outside of a rayon task
solomatov opened this issue · comments
I have some code which blocks (i.e. waits for a mpsc queue). Such code is bad for running inside of rayon. Is there any way to check whether the current code is inside of rayon task or not? I want to create assertions to make sure that this code isn't called from such an inappropriate context and prevent deadlocks.
You can check rayon::current_thread_index()
, which will return None
outside of any pool.
@cuviper Thank you. That's exactly what I was looking for!