Reimplementation of dispatch_group, for educational purposes.