void *thread_func_aew(void *arg) { struct env_aew *env = arg; void *status = THREAD_SUCCESS; struct image_buffer_description *image = NULL; log_enter(); log_dbg("meet\n"); Rendezvous_meet(env->rendezvous_init); while (!gblGetQuit()) { usleep(10000); if (fifo_get(env->fifo_aew, &image) == FIFO_FAILURE) { breakLoop(THREAD_FAILURE); } if (image == NULL) { //阻塞FIFO,只有FIFO中有消息才会执行下去 breakLoop(THREAD_SUCCESS); } capture_buffer_put(image); } Rendezvous_force(env->rendezvous_init); Rendezvous_meet(env->rendezvous_deinit); log("exit aew thread\n"); log_exit(); return status; }
int main(){ node *head; int n; head=NULL; head=createNewNode(11); head->next=createNewNode(12); head->next->next=createNewNode(14); head->next->next->next=createNewNode(15); head->next->next->next->next=createNewNode(16); head->next->next->next->next->next=createNewNode(17); //making a loop //head->next->next->next->next->next->next=head->next->next; head->next->next->next->next->next->next=head->next->next->next->next->next; //1->2->3->4->5->NULL int len; node *temp=NULL; temp=containsLoop(head); if(temp){ printf("\nThe linked list contains the loop"); len=loopLength(head,temp); printf("\nLoop length is:%d",len); if(len==1) temp->next=NULL; else breakLoop(head,len); }else printf("\nThe linked list does not contain any loop"); printf("\nLinked list is:"); printList(head); printf("\n"); return 0; }
void TNonblockingIOThread::stop() { // This should cause the thread to fall out of its event loop ASAP. breakLoop(false); }
void InterfaceAdapter::close() { breakLoop(); wait(); Interface::close(); adp_in = NULL; }
void ParameteredGroupObject::initialize() { ParameteredObject::initialize(); if(_inputs) { std::vector<VirtualInputSlot*> vinput=_inputs->getSlotVector(); for(size_t i=0;i<vinput.size();i++) { VirtualInputSlot* in=vinput[i]; _removeInputSlot(in->getName()); Parameter<int> *par=_loopOutputNumber[i]; _removeSomething("parameters",par->getName()); delete par; breakLoop(i); } } _loopOutputNumber.clear(); if(_outputs) { std::vector<VirtualOutputSlot*> voutput=_outputs->getSlotVector(); for(size_t i=0;i<voutput.size();i++) { VirtualOutputSlot* out=voutput[i]; _removeOutputSlot(out->getName()); } } _inputs=0; _outputs=0; if (_pluginMan!=0) { _pluginMan->reset(); delete _pluginMan; _pluginMan = 0; } _pluginMan = new PluginManager(pluginPaths(),debugSuffix()); _pluginMan->loadParameterFile(workFlowFile()); const std::map<std::string, ParameteredObject*>& objs=_pluginMan->getObjectList(); std::map<std::string, ParameteredObject *>::const_iterator it=objs.begin(); for(;it!=objs.end();it++) { ParameteredObject* obj=it->second; InputSlotBundleIntf* tinputs=dynamic_cast<InputSlotBundleIntf*>(obj); OutputSlotBundleIntf* toutputs=dynamic_cast<OutputSlotBundleIntf*>(obj); if(tinputs) _inputs=tinputs; if(toutputs) _outputs=toutputs; } if(_inputs) { std::vector<VirtualInputSlot*> vinput=_inputs->getSlotVector(); for(size_t i=0;i<vinput.size();i++) { VirtualInputSlot* in=vinput[i]; onAddInputSlot(in); Parameter<int> *par=new Parameter<int>(-1); std::stringstream pname; pname<<"loop_input_"<<i<<"_to_output"; std::stringstream pdoc; pdoc<<"The input "<<i<<" gets the data of the given output after one iteration of a loop. To disable the connection, set to -1"; _addParameter(*par,pname.str(),pdoc.str(),"int"); _loopOutputNumber.push_back(par); } } if(_outputs) { std::vector<VirtualOutputSlot*> voutput=_outputs->getSlotVector(); for(size_t i=0;i<voutput.size();i++) { VirtualOutputSlot* out=voutput[i]; onAddOutputSlot(out); } } initializeGroup(); #pragma message ("need to load slotbundle connections") //_inputs->loadConnection(ParameterFile(workFlowFile),_pluginMan); //_outputs->loadConnection(ParameterFile(workFlowFile),_pluginMan); }
IOObserver::~IOObserver() { if (loop_) { breakLoop(); delete loop_; } }