Solid approach for desktop Linux. Not possible on Unix in a general sense, because cgroups are a Linux-specific thing. They also depend on having certain kernel options enabled.
So if you want to write software that can target MacOS or any of the BSDs, then you can't use cgroups.
So if you want to write software that can target MacOS or any of the BSDs, then you can't use cgroups.