It seems mostly reasonable, but the 'internal' flag doesn't look right. I'd expect that the sync object shouldn't need to worry about such details, that should be up to the owner object. That probably means the signal() operation needs to be handled differently.