I've done this a few times and would have benefited from a utility function for it, apparently it's done in a few more places too. The utilities aren't multithreaded for now, it doesn't seem important and often multithreading happens at a different level of the call stack anyway. Pull Request: https://projects.blender.org/blender/blender/pulls/127517