Client::Client(const QString &IP, int port) : m_IP(IP), m_port(port) { m_tcpSocket = new QTcpSocket(this); connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(readResult())); connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); connect(m_tcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected())); }
ResultStatus Worker::execute(const string& line, vector<string>& result, time_t timeout) { WriteLocker locker(&mutex); result.clear(); if (status != WORKER_RUNNING) { return RESULT_FAILED; } Context::getContext()->check(); if (numFailures >= maxFailures) { // SVS failed to execute the required command, has to be recovered manually by administrator throw WorkerException("SVS script error, can't recover, contact administrator.", false); } boost::shared_ptr<PaloSession> s = PaloSession::findSession(session, false); s->setWorkerContext(Context::getContext()); while (true) { bool ok = sendLine(line, timeout); if (!ok) { if (timeout == 0) { ok = restart(); } if (!ok) { s->setWorkerContext(0); return RESULT_FAILED; } continue; } ok = readResult(timeout); if (!ok) { if (timeout == 0) { ok = restart(); } if (!ok) { s->setWorkerContext(0); return RESULT_FAILED; } continue; } result = this->result; s->setWorkerContext(0); return RESULT_OK; } }
Generator::Generator(QObject *parent) : QObject(parent) { m_Process = new QProcess(this); m_Codec = QTextCodec::codecForName("IBM 866"); connect(m_Process, SIGNAL(readyReadStandardOutput()), this, SLOT(readResult())); connect(m_Process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SIGNAL(finished(int,QProcess::ExitStatus))); }
void WARequest::onResponse() { if (reply->error() == QNetworkReply::NoError) { if (reply->bytesAvailable()) readResult(); else { if (reply) { QObject::connect(reply,SIGNAL(readyRead()),this,SLOT(readResult())); } else { //this->deleteLater(); qDebug() << "broken reply"; } } } else { emit httpError(reply->error()); } }
bool Worker::sendSession() { bool ok = sendLine("SESSION;" + session, 0); if (!ok) { return false; } ok = readResult(0); if (!ok) { return false; } return true; }
void Worker::terminate(const string& line, time_t timeout) { WriteLocker locker(&mutex); if (status != WORKER_RUNNING) { return; } bool ok = sendLine(line, timeout); if (ok) { ok = readResult(timeout); } terminateProcess(); }
void Collision::RenderTree(){ static let path = "C:\\Users\\master8\\Documents\\Visual Studio 2013\\Projects\\assimptest\\assimptest\\result"; if (verts){ let len = verts->size(); for (size_t i = 0; i < len; i+=6) { let el = verts[i]; //初めの3要素は座標、後ろがextent glTranslatef(adec(el,0)); glScalef (adec(el,3)); glutWireCube(1); } } else{ verts = &readResult("C:\\"); RenderTree(); } }
std::string extract_facts( const std::string& filename, folly::StringPiece code ) { if (!isRunning()) { start(); } std::string facts; try { writeExtractFacts(filename, code); return readResult(nullptr /* structured log entry */); } catch (CompileException& ex) { stop(); if (m_options.verboseErrors) { Logger::FError("ExternCompiler Error (facts): {}", ex.what()); } throw; } }
void main() { int sockfd; long serno; char se1[8]; struct sockaddr_in serv_addr; int on=1; if(haveNo()) { bzero((char *) &serv_addr,sizeof(serv_addr)); serv_addr.sin_family=AF_INET; serv_addr.sin_addr.s_addr=inet_addr(SERV_HOST_ADDR); serv_addr.sin_port=htons(SERV_TCP_PORT); if ((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { exit(1); perror("client:"); } if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr))<0) { exit(1); perror("client:"); } /* send my id */ if (write(sockfd,curuser.userid,strlen(curuser.userid))<0) { printf("write to server error\n"); exit(1); } readResult(sockfd); close(sockfd); } exit(1); }
// do-loop for gaming till one player has lost (starting at 1) const unsigned int Game::doStart(const bool contest) { do { #ifdef DEBUG std::cout << "Player's " << m_currentPlayer+1 << " turn!" << std::endl; #endif if ( !writeData() ) { break; } #ifdef DEBUG // print game field m_field.print(); #endif if ( !contest ) { std::cout << "Manually save result.dat and hit enter!" << std::endl; getchar(); } else { // call routine for AI if ( 0 == m_currentPlayer ) { if ( system ("./fm-ai1.bin") ) { std::cout << "Game::doStart() error: calling fm-ai1 failed" << std::endl; // this player will loose the contest m_player[m_currentPlayer].looseAllLife(); break; } } else { if ( system ("./fm-ai2.bin") ) { std::cout << "Game::doStart() error: calling fm-ai2 failed" << std::endl; // this player will loose the contest m_player[m_currentPlayer].looseAllLife(); break; } } } // now we must read the result that has stored to positions FieldPos pos1, pos2; if ( !readResult(pos1, pos2) ) { // file could not be read break; } #ifdef DEBUG std::cout << "Game::doStart() info: swap " << pos1.x() << " " << pos1.y() << " with " << pos2.x() << " " << pos2.y() << std::endl; #endif // delete files deleteFiles(); // switch positions on game field if ( m_field.swapTiles(pos1, pos2) ) { // remove all matching tiles if ( !cascade(contest) ) { break; } } else { #ifdef DEBUG std::cout << "Game::doStart() Illegal move: loose 5 life" << std::endl; #endif m_player[m_currentPlayer].looseLife(5); // getchar(); } // set next player (if necessary) nextPlayer(); // check if gamefield is playable and remove lower lines // until the game is playable again if ( !checkIfPlayable(contest) ) { break; } #ifdef DEBUG // print player info printPlayers(); #endif // getchar(); } while ( !isOnePlayerDead() ); return checkWhosDead(); }
std::unique_ptr<UnitEmitter> compile( const char* filename, const MD5& md5, folly::StringPiece code, const Native::FuncTable& nativeFuncs, bool forDebuggerEval, AsmCallbacks* callbacks ) { if (!isRunning()) { start(); } std::string prog; std::unique_ptr<Unit> u; try { m_compilations++; StructuredLogEntry log; log.setStr("filename", filename); int64_t t = logTime(log, 0, nullptr, true); writeProgram(filename, md5, code, forDebuggerEval); t = logTime(log, t, "send_source"); prog = readResult(&log); t = logTime(log, t, "receive_hhas"); auto ue = assemble_string(prog.data(), prog.length(), filename, md5, nativeFuncs, false /* swallow errors */, callbacks ); logTime(log, t, "assemble_hhas"); if (RuntimeOption::EvalLogExternCompilerPerf) { StructuredLog::log("hhvm_detailed_frontend_performance", log); } return ue; } catch (CompileException& ex) { stop(); if (m_options.verboseErrors) { Logger::FError("ExternCompiler Error: {}", ex.what()); } throw; } catch (CompilerFatal& ex) { // this catch is here so we don't fall into the std::runtime_error one throw; } catch (FatalErrorException&) { // we want these to propagate out of the compiler throw; } catch (AssemblerUnserializationError& ex) { // This (probably) has nothing to do with the php/hhas, so don't do the // verbose error handling we have in the AssemblerError case. throw; } catch (AssemblerError& ex) { if (m_options.verboseErrors) { auto const msg = folly::sformat( "{}\n" "========== PHP Source ==========\n" "{}\n" "========== ExternCompiler Result ==========\n" "{}\n", ex.what(), code, prog); Logger::FError("ExternCompiler Generated a bad unit: {}", msg); // Throw the extended message to ensure the fataling unit contains the // additional context throw AssemblerError(msg); } throw; } catch (std::runtime_error& ex) { if (m_options.verboseErrors) { Logger::FError("ExternCompiler Runtime Error: {}", ex.what()); } throw; } }