void __DisplayVblankBeginCallback(SceUID threadID, SceUID prevCallbackId) { SceUID pauseKey = prevCallbackId == 0 ? threadID : prevCallbackId; // This means two callbacks in a row. PSP crashes if the same callback waits inside itself (may need more testing.) // TODO: Handle this better? if (vblankPausedWaits.find(pauseKey) != vblankPausedWaits.end()) { return; } WaitVBlankInfo waitData(0); for (size_t i = 0; i < vblankWaitingThreads.size(); i++) { WaitVBlankInfo *t = &vblankWaitingThreads[i]; if (t->threadID == threadID) { waitData = *t; vblankWaitingThreads.erase(vblankWaitingThreads.begin() + i); break; } } if (waitData.threadID != threadID) { WARN_LOG_REPORT(SCEDISPLAY, "sceDisplayWaitVblankCB: could not find waiting thread info."); return; } vblankPausedWaits[pauseKey] = vCount + waitData.vcountUnblock; DEBUG_LOG(SCEDISPLAY, "sceDisplayWaitVblankCB: Suspending vblank wait for callback") }
void TwsDL::idle() { waitData(); if( quit || currentRequest.reqType() != GenericRequest::NONE ) { return; } if( !twsClient->isConnected() ) { connectTws(); return; } // HACK static int f****e = 0; if( f****e <= 0 ) { f****e = reqMktData(); } GenericRequest::ReqType reqType = workTodo->nextReqType(); switch( reqType ) { case GenericRequest::ACC_STATUS_REQUEST: reqAccStatus(); break; case GenericRequest::EXECUTIONS_REQUEST: reqExecutions(); break; case GenericRequest::ORDERS_REQUEST: reqOrders(); break; case GenericRequest::CONTRACT_DETAILS_REQUEST: reqContractDetails(); break; case GenericRequest::HIST_REQUEST: reqHistoricalData(); break; case GenericRequest::NONE: /* TODO for now we place all orders when nothing else todo */ if( strat != NULL ) { work_dso( strat, this ); } placeAllOrders(); break; } if( reqType == GenericRequest::NONE && f****e <= 1 && p_orders.empty() ) { _lastError = "No more work to do."; quit = true; } }
std::string NetClient::receiveLine() throw(const SocketException &) { // sub-optimal implementation grabs one character at a time.. char c; int num; std::string ret = ""; while(1) { if (!nReadyForRead() && !waitData(read_timeout_secs * 1000)) break; num = receiveData(&c, 1); if (!num) break; if (c == '\n') break; ret += c; } return ret; }
void ParticleDumperPlugin::handshake() { auto req = waitData(); MPI_Check( MPI_Wait(&req, MPI_STATUS_IGNORE) ); recv(); std::vector<int> sizes; std::vector<std::string> names; SimpleSerializer::deserialize(data, sizes, names); auto init_channel = [] (XDMF::Channel::DataForm dataForm, int sz, const std::string& str, XDMF::Channel::NumberType numberType = XDMF::Channel::NumberType::Float, TypeDescriptor datatype = DataTypeWrapper<float>()) { return XDMF::Channel(str, nullptr, dataForm, numberType, datatype); }; // Velocity and id are special channels which are always present std::string allNames = "velocity, id"; channels.push_back(init_channel(XDMF::Channel::DataForm::Vector, 3, "velocity", XDMF::Channel::NumberType::Float, DataTypeWrapper<float>())); channels.push_back(init_channel(XDMF::Channel::DataForm::Scalar, 1, "id", XDMF::Channel::NumberType::Int64, DataTypeWrapper<int64_t>())); for (int i = 0; i<sizes.size(); i++) { allNames += ", " + names[i]; switch (sizes[i]) { case 1: channels.push_back(init_channel(XDMF::Channel::DataForm::Scalar, sizes[i], names[i])); break; case 3: channels.push_back(init_channel(XDMF::Channel::DataForm::Vector, sizes[i], names[i])); break; case 6: channels.push_back(init_channel(XDMF::Channel::DataForm::Tensor6, sizes[i], names[i])); break; default: die("Plugin '%s' got %d as a channel '%s' size, expected 1, 3 or 6", name.c_str(), sizes[i], names[i].c_str()); } } // Create the required folder createFoldersCollective(comm, parentPath(path)); debug2("Plugin '%s' was set up to dump channels %s. Path is %s", name.c_str(), allNames.c_str(), path.c_str()); }
CANSocket::CANSocketReadSuccess CANSocketRaw::read(struct CANFrameInfo& message, unsigned int timeout) { LOG_TRACE("timeout: " << timeout); CANSocket::CANSocketReadSuccess success; memset(&message, 0, sizeof(message)); switch(waitData(timeout)) { case -1: LOG_ERROR("reading error"); success = CANSocket::READING_FAILED; break; case 0: success = CANSocket::READING_TIMED_OUT; break; default: ssize_t nbytes = (int)readFrame(message.frame, message.timestamp); message.status = CANFrameInfo::CANMessageStatus::GOOD; success = nbytes > 0 ? CANSocket::READING_SUCCEEDED : CANSocket::READING_FAILED; } return success; }
void PlumedMain::performCalc(){ waitData(); justCalculate(); backwardPropagate(); update(); }
void cDvbCi::slot_pollthread(void *c) { ca_slot_info_t info; unsigned char data[1024]; tSlot* slot = (tSlot*) c; while (1) { int len = 1024; unsigned char* d; eData status; switch (slot->status) { case eStatusNone: { if (slot->camIsReady) { if (sendCreateTC(slot)) { slot->status = eStatusWait; slot->camIsReady = true; } else { usleep(100000); } } else { /* wait for pollpri */ status = waitData(slot->fd, data, &len); if (status == eDataStatusChanged) { info.num = slot->slot; if (ioctl(slot->fd, CA_GET_SLOT_INFO, &info) < 0) printf("IOCTL CA_GET_SLOT_INFO failed for slot %d\n", slot->slot); //printf("flags %d %d %d ->slot %d\n", info.flags, CA_CI_MODULE_READY, info.flags & CA_CI_MODULE_READY, slot->slot); if (info.flags & CA_CI_MODULE_READY) { printf("1. cam (%d) status changed ->cam now present\n", slot->slot); slot->mmiSession = NULL; slot->hasMMIManager = false; slot->hasCAManager = false; slot->hasDateTime = false; slot->hasAppManager = false; slot->mmiOpened = false; slot->init = false; sprintf(slot->name, "unknown module %d", slot->slot); slot->status = eStatusNone; if (g_RCInput) g_RCInput->postMsg(NeutrinoMessages::EVT_CI_INSERTED, slot->slot); slot->camIsReady = true; //setSource(slot); } else { //noop } } } } /* case statusnone */ break; case eStatusWait: { status = waitData(slot->fd, data, &len); if (status == eDataReady) { //int s_id = data[0]; //int c_id = data[1]; slot->pollConnection = false; //printf("%d: s_id = %d, c_id = %d\n", slot->slot, s_id, c_id); d = data; /* taken from the dvb-apps */ int data_length = len - 2; d += 2; /* remove leading slot and connection id */ while (data_length > 0) { unsigned char tpdu_tag = d[0]; unsigned short asn_data_length; int length_field_len; if ((length_field_len = asn_1_decode(&asn_data_length, d + 1, data_length - 1)) < 0) { printf("Received data with invalid asn from module on slot %02x\n", slot->slot); break; } if ((asn_data_length < 1) || (asn_data_length > (data_length - (1 + length_field_len)))) { printf("Received data with invalid length from module on slot %02x\n", slot->slot); break; } slot->connection_id = d[1 + length_field_len]; //printf("Setting connection_id from received data to %d\n", slot->connection_id); d += 1 + length_field_len + 1; data_length -= (1 + length_field_len + 1); asn_data_length--; process_tpdu(slot, tpdu_tag, d, asn_data_length, slot->connection_id); // skip over the consumed data d += asn_data_length; data_length -= asn_data_length; } // while (data_length) } /* data ready */ else if (status == eDataWrite) { if (!slot->sendqueue.empty()) { const queueData &qe = slot->sendqueue.top(); int res = write(slot->fd, qe.data, qe.len); if (res >= 0 && (unsigned int)res == qe.len) { delete [] qe.data; slot->sendqueue.pop(); } else { printf("r = %d, %m\n", res); } } else { //printf("sendqueue emtpy\n"); if ((checkQueueSize(slot) == false) && ((!slot->hasCAManager) || (slot->mmiOpened))) slot->pollConnection = true; } } else if (status == eDataStatusChanged) { info.num = slot->slot; if (ioctl(slot->fd, CA_GET_SLOT_INFO, &info) < 0) printf("IOCTL CA_GET_SLOT_INFO failed for slot %d\n", slot->slot); printf("flags %d %d %d ->slot %d\n", info.flags, CA_CI_MODULE_READY, info.flags & CA_CI_MODULE_READY, slot->slot); if ((slot->camIsReady == false) && (info.flags & CA_CI_MODULE_READY)) { printf("2. cam (%d) status changed ->cam now present\n", slot->slot); slot->mmiSession = NULL; slot->hasMMIManager = false; slot->hasCAManager = false; slot->hasDateTime = false; slot->hasAppManager = false; slot->mmiOpened = false; slot->init = false; sprintf(slot->name, "unknown module %d", slot->slot); slot->status = eStatusNone; if (g_RCInput) g_RCInput->postMsg(NeutrinoMessages::EVT_CI_INSERTED, slot->slot); slot->camIsReady = true; } else if ((slot->camIsReady == true) && (!(info.flags & CA_CI_MODULE_READY))) { printf("cam (%d) status changed ->cam now _not_ present\n", slot->slot); eDVBCISession::deleteSessions(slot); slot->mmiSession = NULL; slot->hasMMIManager = false; slot->hasCAManager = false; slot->hasDateTime = false; slot->hasAppManager = false; slot->mmiOpened = false; slot->init = false; sprintf(slot->name, "unknown module %d", slot->slot); slot->status = eStatusNone; if (g_RCInput) g_RCInput->postMsg(NeutrinoMessages::EVT_CI_REMOVED, slot->slot); while(slot->sendqueue.size()) { delete [] slot->sendqueue.top().data; slot->sendqueue.pop(); } slot->camIsReady = false; usleep(100000); } } if (!checkQueueSize(slot) && slot->pollConnection) { //printf("poll\n"); sendData(slot, NULL, 0); } } break; default: printf("unknown state %d\n", slot->status); break; } if (slot->hasCAManager && slot->hasAppManager && !slot->init) //declare this as init, but remeber we are still not complete! { slot->init = true; if (g_RCInput) g_RCInput->postMsg(NeutrinoMessages::EVT_CI_INIT_OK, slot->slot); //resend a capmt if we have one. this is not very proper but I cant any mechanism in //neutrino currently. so if a cam is inserted a pmt is not resend if (slot->caPmt != NULL) { SendCaPMT(slot->caPmt, slot->source); } } } }
void Spi::deSelect() { waitData(); chipSelect(-1); }