int internal_opque_add(opque_t *que, op_generic_t *gop, int dolock) { int err = 0; callback_t *cb; que_data_t *q = &(que->qd); //** Create the callback ** type_malloc(cb, callback_t, 1); callback_set(cb, _opque_cb, (void *)gop); //** Set the global callback for the list if (dolock != 0) lock_opque(q); log_printf(15, "opque_add: qid=%d gid=%d\n", que->op.base.id, gop_get_id(gop)); //** Add the list CB to the the op // lock_gop(gop) gop->base.parent_q = que; callback_append(&(gop->base.cb), cb); // unlock_gop(gop) //**Add the op to the q q->nsubmitted++; q->nleft++; if (q->opque->op.base.started_execution == 0) { move_to_bottom(q->list); insert_below(q->list, (void *)cb); } if (dolock != 0) unlock_opque(q); if (q->opque->op.base.started_execution == 1) { if (gop->type == Q_TYPE_OPERATION) { log_printf(15, "gid=%d started_execution=%d\n", gop_get_id(gop), gop->base.started_execution); gop->base.started_execution = 1; gop->base.pc->fn->submit(gop->base.pc->arg, gop); } else { //** It's a queue opque_start_execution(gop->q->opque); } } return(err); }
void gop_callback_append(op_generic_t *gop, callback_t *cb) { lock_gop(gop); callback_append(&(gop->base.cb), cb); unlock_gop(gop); }