wait on cond variable instead of sleeping