added some prototypes, init/finish with cond var for task attaching