void PipelinedModCodec::process_thread() { set_thread_name(name()); set_realtime_prio(1); while (m_running) { Buffer dataIn; m_input_queue.wait_and_pop(dataIn); if (dataIn.getLength() == 0) { break; } Buffer dataOut; dataOut.setLength(dataIn.getLength()); if (internal_process(&dataIn, &dataOut) == 0) { m_running = false; } m_output_queue.push(std::move(dataOut)); } m_running = false; }
/** * Takes a linkage and returns: * . for each link, the domain structure of that link * . a list of the violation strings * NB: linkage->link[i]->l=-1 means that this connector is to be ignored. */ PP_node *do_post_process(Postprocessor *pp, Linkage sublinkage, bool is_long) { const char *msg; if (pp == NULL) return NULL; // XXX wtf .. why is this not leaking memory ? pp->pp_data.links_to_ignore = NULL; pp->pp_data.num_words = sublinkage->num_words; /* Grab more memory if needed */ if (pp->vlength <= pp->pp_data.num_words) { size_t newsz; pp->vlength += pp->pp_data.num_words; newsz = pp->vlength * sizeof(bool); pp->visited = (bool *) realloc(pp->visited, newsz); } clear_visited(pp); /* In the name of responsible memory management, we retain a copy of the * returned data structure pp_node as a field in pp, so that we can clear * it out after every call, without relying on the user to do so. */ clear_pp_node(pp); /* For long sentences, we can save some time by pruning the rules * which can't possibly be used during postprocessing the linkages * of this sentence. For short sentences, this is pointless. */ if (is_long && pp->q_pruned_rules == false) { prune_irrelevant_rules(pp); } pp->q_pruned_rules = true; switch (internal_process(pp, sublinkage, &msg)) { case -1: /* some global test failed even before we had to build the domains */ pp->n_global_rules_firing++; pp->pp_node->violation = msg; report_pp_stats(pp); return pp->pp_node; break; case 1: /* one of the "normal" post processing tests failed */ pp->n_local_rules_firing++; pp->pp_node->violation = msg; break; case 0: /* This linkage is legal according to the post processing rules */ pp->pp_node->violation = NULL; break; } report_pp_stats(pp); build_type_array(pp); return pp->pp_node; }
PP_node *post_process(Postprocessor *pp, Parse_Options opts, Sentence sent, Sublinkage *sublinkage, int cleanup) { /* Takes a sublinkage and returns: . for each link, the domain structure of that link . a list of the violation strings NB: sublinkage->link[i]->l=-1 means that this connector is to be ignored*/ char *msg; if (pp==NULL) return NULL; pp->pp_data.links_to_ignore = NULL; pp->pp_data.length = sent->length; /* In the name of responsible memory management, we retain a copy of the returned data structure pp_node as a field in pp, so that we can clear it out after every call, without relying on the user to do so. */ reset_pp_node(pp); /* The first time we see a sentence, prune the rules which we won't be needing during postprocessing the linkages of this sentence */ if (sent->q_pruned_rules==FALSE && sent->length >= opts->twopass_length) prune_irrelevant_rules(pp); sent->q_pruned_rules=TRUE; switch(internal_process(pp, sublinkage, &msg)) { case -1: /* some global test failed even before we had to build the domains */ pp->n_global_rules_firing++; pp->pp_node->violation = msg; return pp->pp_node; break; case 1: /* one of the "normal" post processing tests failed */ pp->n_local_rules_firing++; pp->pp_node->violation = msg; break; case 0: /* This linkage is legal according to the post processing rules */ pp->pp_node->violation = NULL; break; } build_type_array(pp); if (cleanup) post_process_free_data(&pp->pp_data); return pp->pp_node; }