impl mac semaphore
impl semaphore for ios