void Widget::on_pushButton_clicked() { num = 0; initBarrier(); m_bird->reBegin(); m_bird->setPos(0,0); for(int i=0;i<BARRIER_NUM;i++) { m_barr[i]->reBegin(); } hideButton(); QTimer::singleShot(3000,this,SLOT(delayBeigin())); scene()->update(scene()->sceneRect()); }
Widget::Widget(QWidget *parent) : QGraphicsView(parent), ui(new Ui::Widget) { ui->setupUi(this); m_scene = new QGraphicsScene; setScene(m_scene); m_scene->setSceneRect(3-width()/2,3-height()/2,width()-6,height()-6); m_bird = new bird(); m_scene->addItem(m_bird); m_bird->setPos(0,0); m_edge_1 = new edge(); m_scene->addItem(m_edge_1); m_edge_1->setPos(m_edge_1->boundingRect().width()/4,-height()/2+7); m_edge_2 = new edge(); m_scene->addItem(m_edge_2); m_edge_2->setPos(m_edge_2->boundingRect().width()/4,height()/2-7); m_edge_1->BeginMove(); m_edge_2->BeginMove(); hideButton(); m_timer = new QTimer(this); connect(m_timer,SIGNAL(timeout()),this,SLOT(beginBarrier()));//barrier connect(m_bird,SIGNAL(died()),this,SLOT(onBirdDied())); for(int i =0;i<BARRIER_NUM;i++) { m_barr[i] = new barrier(); m_scene->addItem(m_barr[i]); } initBarrier(); num = 0; QTimer::singleShot(1000,this,SLOT(Scoring())); score = 0; ScoringTimer = new QTimer(this); connect(ScoringTimer,SIGNAL(timeout()),this,SLOT(Scoring())); settings = new QSettings("score.ini",QSettings::IniFormat); // setWindowFlags(Qt::FramelessWindowHint); }
initbarcom() { initBarrier(10); initialDDRSyncComm(); }
//Basic test for create/attach and exit. int pc_thread_cont_mutatee() { int result; int error = 0; int i; struct local_data *localData = NULL; handshake can_stop; allow_exit can_exit; num_threads = 0; for (i = 0; i < gargc; i++) { if (strcmp(gargv[i], "-mt") == 0) { num_threads = atoi(gargv[i+1]); break; } } if( num_threads > 0 ) { // Each thread needs its own mutex and access to the barrier localData = (struct local_data *)malloc(sizeof(struct local_data)); initBarrier(&localData->barrier, num_threads+1); localData->myLocks = (testlock_t *)malloc(sizeof(testlock_t)*num_threads); for(i = 0; i < num_threads; ++i) { initLock(&localData->myLocks[i]); testLock(&localData->myLocks[i]); } } result = initProcControlTest(threadFunc, (void *)localData); if (result != 0) { output->log(STDERR, "Initialization failed\n"); if( num_threads > 0 ) freeLocalData(localData); return -1; } if( num_threads > 0 ) { logstatus("initial thread: waiting on barrier\n"); waitTestBarrier(&localData->barrier); // Alert the mutator that all the threads have gotten through the lock // and can safely be stopped now can_stop.code = HANDSHAKE_CODE; send_message((unsigned char *)&can_stop, sizeof(handshake)); // Wait for mutator to indicate that the stop finished memset(&can_stop, 0, sizeof(handshake)); recv_message((unsigned char *)&can_stop, sizeof(handshake)); if (can_stop.code != HANDSHAKE_CODE) { output->log(STDERR, "Received event that wasn't handshake\n"); error = 1; } logstatus("initial thread: received stop handshake, releasing threads\n"); // Release all the locks for(i = 0; i < num_threads; ++i) { testUnlock(&localData->myLocks[i]); } // Alert mutator that all threads can be continued when ready memset(&can_stop, 0, sizeof(handshake)); can_stop.code = HANDSHAKE_CODE; send_message((unsigned char *)&can_stop, sizeof(handshake)); logstatus("initial thread: all threads can be continued\n"); } recv_message((unsigned char *) &can_exit, sizeof(allow_exit)); if (can_exit.code != ALLOWEXIT_CODE) { output->log(STDERR, "Recieved event that wasn't allow_exit\n"); error = 1; } result = finiProcControlTest(0); if (result != 0) { output->log(STDERR, "Finalization failed\n"); if( num_threads > 0 ) freeLocalData(localData); return -1; } if (error) { if( num_threads > 0 ) freeLocalData(localData); return -1; } if( num_threads > 0 ) freeLocalData(localData); test_passes(testname); return 0; }