예제 #1
0
void 
C64::synchronizeTiming()
{
    const uint64_t earlyWakeup = 1500000; /* 1.5 milliseconds */
    const uint64_t maxJitter = 1000000000; /* 1 second */

    // Convert usec into kernel unit and sleep
    uint64_t kernelTargetTime = nanos_to_abs(nanoTargetTime);
    int64_t jitter = sleepUntil(kernelTargetTime, earlyWakeup);

    // Update target time
    nanoTargetTime += vic->getFrameDelay();

    // debug(2, "Jitter = %d", jitter);
    if (jitter > maxJitter) {
        
        // The emulator did not keep up with the real time clock. Instead of
        // running behind for a long time, we reset the synchronization timer
        
        debug(2, "Jitter exceeds limit. Restarting synchronization timer.\n"); 
        restartTimer();
    }

#if 0
    // Old sleep
    // determine how long we should wait
    uint64_t timeToSleep = targetTime - usec();
    targetTime += vic->getFrameDelay() / 1000; // OLD
	if (timeToSleep > 0) {
		sleepMicrosec(timeToSleep);
	} else {
		restartTimer();
	}
#endif
}
예제 #2
0
void 
C64::synchronizeTiming()
{
    const uint64_t earlyWakeup = 1500000; /* 1.5 milliseconds */

    // Convert usec into kernel unit
    int64_t kernelTargetTime = nanos_to_abs(nanoTargetTime);

    // Check how long we're supposed to sleep
    int64_t timediff = kernelTargetTime - (int64_t)mach_absolute_time();
    if (timediff > 200000000 /* 0.2 sec */) {

        // The emulator seems to be out of sync, so we better reset the synchronization timer
        
        debug(2, "Emulator lost synchronization (%lld). Restarting synchronization timer.\n", timediff);
        restartTimer();
        // return;
    }

    // Sleep and update target timer
    // debug(2, "%p Sleeping for %lld\n", this, kernelTargetTime - mach_absolute_time());
    int64_t jitter = sleepUntil(kernelTargetTime, earlyWakeup);
    nanoTargetTime += vic->getFrameDelay();

    // debug(2, "Jitter = %d", jitter);
    if (jitter > 1000000000 /* 1 sec */) {
        
        // The emulator did not keep up with the real time clock. Instead of
        // running behind for a long time, we reset the synchronization timer
        
        debug(2, "Jitter exceeds limit (%lld). Restarting synchronization timer.\n", jitter);
        restartTimer();
    }
}
예제 #3
0
void CImageReceiverWorker::receiveCallBack(const QByteArray& receiveStr)
{
    restartTimer(true);
    pMatWithTimeStamp matPtr;
    matPtr.reset(new CMatWithTimeStamp(
                     CConfig::getInstance().
                     mInputConfig->mInputList[mBufferId].mResizeScaleFactor));
    std::string errString;

    if (tryLoadMat(receiveStr, errString, matPtr))
    {

    }
    else
    {
        if (!CImageBuffer::getBufferInstance().empty(mBufferId))
        {
            LOG_DEBUG << "fail desialize:" << errString << "buffer size" << CImageBuffer::getBufferInstance().size(mBufferId)
                      << "\n    last timestamp:" << CImageBuffer::getBufferInstance().getLast(mBufferId)->getDateTimeWithMS()
                      << "id:" <<  CImageBuffer::getBufferInstance().getLast(mBufferId)->getId()
                      << "size:" << receiveStr.size() << "bufferId:" << mBufferId;
        }
        else
        {
            LOG_DEBUG << "fail desialize:" << errString
                      << "size:" << receiveStr.size()
                      << mpNet->getConnectionConfig()
                      << "buffer size:" << CImageBuffer::getBufferInstance().size(mBufferId);
        }
    }
    mErrorNumber = 0;
    restartTimer();

    mRequestTimer.start();
}
예제 #4
0
void NetworkManager::sendServiceMessageToMobile(const Message& message)
{
  QNetworkRequest request;

  request.setUrl(QUrl(mobileParams_.server));
  request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));

  QUrlQuery params;
  params.addQueryItem("text", QUrl::toPercentEncoding(message.text));
  params.addQueryItem("id", QString::number(7777));
  params.addQueryItem("priority", QString::number(0));
  params.addQueryItem("time", message.receiveTime.toString());

  if (cache_.logging)
  {
    Loggers::net->info() << params.query();
  }

  QNetworkReply* reply = manager_->post(request, params.query().toUtf8());
  if (reply)
	{
		auto handler = [=](QNetworkReply* reply)
		{
			if(reply->error() != QNetworkReply::NoError)
			{
				Loggers::app->warn() << "gor error in sendServiceMessageToMobile";
			}
		};

		restartTimer(reply, handler);
  }
}
예제 #5
0
void NetworkManager::userMessageRequest(const Callback<const Message&>& callback)
{
  QNetworkReply* reply = sendRequest("GET_MESSAGES");
  if (reply)
	{
		auto handler = [=](QNetworkReply* reply)
		{
			if(reply->error() == QNetworkReply::NoError)
			{
				parseMessageXml(reply->readAll(), callback);
			}
			else
			{
				Loggers::net->error() << "gor error in GET_MESSAGES";

				if (callback)
				{
					callback(OpResult::RequestError, Message());
				}
			}
		};

		restartTimer(reply, handler);
  }
}
void LLUpdaterServiceImpl::startChecking(bool install_if_ready)
{
    if(mChannel.empty() || mVersion.empty())
    {
        throw LLUpdaterService::UsageError("Set params before call to "
                                           "LLUpdaterService::startCheck().");
    }

    mIsChecking = true;

    // Check to see if an install is ready.
    bool has_install = checkForInstall(install_if_ready);
    if(!has_install)
    {
        checkForResume(); // will set mIsDownloading to true if resuming

        if(!mIsDownloading)
        {
            setState(LLUpdaterService::CHECKING_FOR_UPDATE);

            // Checking can only occur during the mainloop.
            // reset the timer to 0 so that the next mainloop event
            // triggers a check;
            restartTimer(0);
        }
        else
        {
            setState(LLUpdaterService::DOWNLOADING);
        }
    }
}
예제 #7
0
파일: mainwindow.cpp 프로젝트: SgLy/hexakis
void MainWindow::mode_switch()
{
	ui->graphicsView->fitInView(QRectF(0, 0, BOARD_WIDTH * BOARD_TILE_SIZE,
		BOARD_HEIGHT * BOARD_TILE_SIZE), Qt::KeepAspectRatio);
	ui->nextView->fitInView(QRectF(0, 0, 4*BOARD_TILE_SIZE,
		4*BOARD_TILE_SIZE), Qt::KeepAspectRatio);
	switch (state) {
	case STATE_INIT:
		game->Reset();
		game->Start();
		drawNext(game->next);
		state = STATE_RUNNING;
		score = 0;
		refreshScore();
		ui->pushButton->setText("Pause");
		ui->actionStart_Game->setText("Pause");
		goto start_timer;
	case STATE_RUNNING:
		game->Pause();
		timer->stop();
		ui->pushButton->setText("Resume");
		ui->actionStart_Game->setText("Resume");
		state = STATE_PAUSE;
		return;
	case STATE_PAUSE:
		game->Resume();
		ui->pushButton->setText("Pause");
		ui->actionStart_Game->setText("Pause");
		state = STATE_RUNNING;
		goto start_timer;
	}
	start_timer:
	restartTimer ();
	redraw();
}
예제 #8
0
Game::Game() :  KTopLevelWidget()
{
    setCaption( kapp->getCaption() );

    setIcon(klocale->translate("Snake Race"));

    conf = kapp->getConfig();
    if(conf == NULL) {
	printf(klocale->translate("KConfig error ??\n"));
	kapp->quit();
    }

    levels = new Levels();
    score  = new Score;
    menu();
    checkMenuItems();

    View *view = new View(this);
    rattler = view->rattler;
    rattler->setFocus();

    connect(rattler, SIGNAL(setPoints(int)), view->lcd, SLOT(display(int)));
    connect(rattler, SIGNAL(setTrys(int)), view->trys, SLOT(set(int)));
    connect(rattler, SIGNAL(rewind()), view->pg, SLOT(rewind()));
    connect(rattler, SIGNAL(advance()), view->pg, SLOT(advance()));
    connect(view->pg, SIGNAL(restart()), rattler, SLOT(restartTimer()));

    connect(rattler, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
    connect(rattler, SIGNAL(setScore(int)), score, SLOT(setScore(int)));

    menubar->show();
    setMenu(menubar);
    view->show();
    setView(view);
}
예제 #9
0
void Timer::stopTimer()
{
    timer->stop();
    restartTimer();

    disconnect( timer, SIGNAL(timeout()), this, SLOT(startTicking()) );
}
예제 #10
0
int emuswitch_process(struct net_bridge_throttle_state *state, 
		      struct sk_buff *skb) {
	static int maxqlen = 0;
	//emuswitch_thunk_t thunk = EMUSWITCH_SKB_CB(skb)->thunk;
	//emuswitch_thunkstate_t thunkState = EMUSWITCH_SKB_CB(skb)->thunkstate;
	maxqlen = max(maxqlen, state->maxQueueLen);

	if(state->queue.qlen < state->maxQueueLen) {
		int oldQlen = state->queue.qlen;
		__skb_queue_tail(&state->queue, skb);
#if 0 // microoptimization
		if(oldQlen == 0) {
			restartTimer(state);
		}
#endif
		//printk("queue length %d\n", state->queue.qlen);
	} else {
		// Drop packet
		printk("dropped packet\n");
		__kfree_skb(skb);
	}
	if(state->queue.qlen > 200) {
		printk("queue length: %d/%d\n", state->queue.qlen, state->maxQueueLen);
	}
	return 1;
}
예제 #11
0
void SysEventMonitor::init() {
#ifdef _WIN32
    createWinId();
    sysEventProviderSvc_.start(SysEventProviderSvcPath);
    restartTimer();
#endif
}
예제 #12
0
void NetworkManager::emptyXmlRequest(const Callback<>& callback)
{
  QNetworkReply* reply = sendRequest("PING");
  if (reply)
	{
		auto handler = [=](QNetworkReply* reply)
		{
			if(reply->error() == QNetworkReply::NoError)
			{
				if (callback)
				{
					callback(OpResult::Success);
				}
			}
			else
			{
				Loggers::app->critical() << "got error in PING " << reply->error();

				if (callback)
				{
					callback(OpResult::RequestError);
				}
			}
		};

		restartTimer(reply, handler);
  }
}
예제 #13
0
bool SysEventMonitor::nativeEvent(const QByteArray & eventType, void * message, long * result) {
#ifdef _WIN32
    static const QByteArray GenericMsgType("windows_generic_MSG");

    if (eventType == GenericMsgType) {
        const MSG * const pMsg = static_cast<const MSG * const>(message);

        if (pMsg->message == SysEventMessages::DesktopLock) {
            Logger::logEvent(Logger::WorkstationLocked);
            myTimer_.stop();
            emit desktopLocked();
        } else if (pMsg->message == SysEventMessages::DesktopUnlock) {
            Logger::logEvent(Logger::WorkstationUnlocked);
            restartTimer();
            emit desktopUnlocked();
        } else if (pMsg->message == SysEventMessages::StartScreenSaver) {
            myTimer_.stop();
            emit screensaverStarted();
        } else if (pMsg->message == SysEventMessages::StopScreenSaver) {
            restartTimer();
            emit screensaverStopped();
        } else if (pMsg->message == SysEventMessages::PowerModeSusped) {
            Logger::logEvent(Logger::PowerModeSuspended);
            myTimer_.stop();
            emit powerModeSuspended();
        } else if (pMsg->message == SysEventMessages::PowerModeResume) {
            Logger::logEvent(Logger::PowerModeResumed);
            restartTimer();
            emit powerModeResumed();
        } else {
            //unknown message, allow further processing
            return false;
        }

        //stop processing
        *result = 0;
        return true;
    }
#else
    Q_UNUSED(result);
    Q_UNUSED(message);
    Q_UNUSED(eventType);
#endif

    //not our message, allow further processing
    return false;
}
void LLUpdaterServiceImpl::error(std::string const & message)
{
    if(mIsChecking)
    {
        setState(LLUpdaterService::TEMPORARY_ERROR);
        restartTimer(mCheckPeriod);
    }
}
예제 #15
0
void
C64::setWarp(bool b)
{
	if (warp != b) {
		warp = b;
		restartTimer();
		putMessage(MSG_WARP, b);
	}
}
예제 #16
0
void LLUpdaterServiceImpl::upToDate(void)
{
	if(mIsChecking)
	{
		restartTimer(mCheckPeriod);
	}
	
	setState(LLUpdaterService::UP_TO_DATE);
}
예제 #17
0
/**
 * @brief updates the time
 * Color and font settings can be configured in Qt CSS
 */
void LxQtClock::updateTime()
{
    QDateTime now = currentDateTime();

    if (now.time().msec() > 500)
        restartTimer(now);

    showTime(now);
}
void IdlenessWatcher::UnInhibit(uint cookie)
{
    qDebug() << "*** Uninhibit" << cookie;
    mDBusWatcher.removeWatchedService(mInhibitors.value(cookie));
    mInhibitors.remove(cookie);

    if (mInhibitors.isEmpty())
        restartTimer();
}
// A successful response was received from the viewer version manager
void LLUpdaterServiceImpl::response(LLSD const & content)
{
    if(!content.asBoolean()) // an empty response means "no update"
    {
        LL_INFOS("UpdaterService") << "up to date" << LL_ENDL;
        if(mIsChecking)
        {
            restartTimer(mCheckPeriod);
        }

        setState(LLUpdaterService::UP_TO_DATE);
    }
    else if ( content.isMap() && content.has("url") )
    {
        // there is an update available...
        stopTimer();
        mNewChannel = content["channel"].asString();
        if (mNewChannel.empty())
        {
            LL_INFOS("UpdaterService") << "no channel supplied, assuming current channel" << LL_ENDL;
            mNewChannel = mChannel;
        }
        mNewVersion = content["version"].asString();
        mIsDownloading = true;
        setState(LLUpdaterService::DOWNLOADING);
        BOOL required = content["required"].asBoolean();
        LLURI url(content["url"].asString());
        std::string more_info = content["more_info"].asString();
        LL_DEBUGS("UpdaterService")
                << "Starting download of "
                << ( required ? "required" : "optional" ) << " update"
                << " to channel '" << mNewChannel << "' version " << mNewVersion
                << " more info '" << more_info << "'"
                << LL_ENDL;
        mUpdateDownloader.download(url, content["hash"].asString(), mNewChannel, mNewVersion, more_info, required);
    }
    else
    {
        LL_WARNS("UpdaterService") << "Invalid update query response ignored; retry in "
                                   << mCheckPeriod << " seconds" << LL_ENDL;
        restartTimer(mCheckPeriod);
    }
}
예제 #20
0
void CImageReceiverWorker::timerConnectTimeout()
{
    mConnectTimer.stop();
    if (mpNet->isReady())
    {
        restartTimer();
        sendImageRequest();
    }
    else
    {
        onError(QAbstractSocket::SocketTimeoutError, "timeout");
    }
}
예제 #21
0
static inline void 
enable_nb_throttle_state(struct net_bridge_throttle_state *state) {
	if(!state->useThrottle) {
		state->useThrottle = 1;
		BUG_TRAP(state->maxQueueLen > 0);
		BUG_TRAP(state->bytesPerSecond > 0);

		BUG_TRAP(!timer_pending(&state->queue_timer));
		restartTimer(state);
		printk("timer set\n");

		do_gettimeofday(&state->lastTV);
	}
}
void IdlenessWatcher::serviceUnregistered(const QString& service)
{
    for (QMutableMapIterator<uint, QString> iter(mInhibitors); iter.hasNext();)
    {
        if (iter.next().value() == service)
        {
            qDebug() << "Service unregistered:" << iter.value();
            mDBusWatcher.removeWatchedService(iter.value());
            iter.remove();
        }
    }

    if (mInhibitors.isEmpty())
        restartTimer();
}
예제 #23
0
void LxQtClock::settingsChanged()
{
    mTimeFormat = settings()->value("timeFormat", QLocale::system().timeFormat(QLocale::ShortFormat).toUpper().contains("AP") ? "h:mm AP" : "HH:mm").toString();

    mUseUTC = settings()->value("UTC", false).toBool();
    if (mUseUTC)
        mTimeFormat += "' Z'";

    mDateFormat = settings()->value("dateFormat", Qt::SystemLocaleShortDate).toString();

    bool dateBeforeTime = (settings()->value("showDate", "no").toString().toLower() == "before");
    bool dateAfterTime = (settings()->value("showDate", "no").toString().toLower() == "after");
    mDateOnNewLine = (settings()->value("showDate", "no").toString().toLower() == "below");

    bool autoRotate = settings()->value("autoRotate", true).toBool();
    if (autoRotate != mAutoRotate)
    {
        mAutoRotate = autoRotate;
        realign();
    }


    if (dateBeforeTime)
        mClockFormat = QString("%1 %2").arg(mDateFormat).arg(mTimeFormat);
    else if (dateAfterTime)
        mClockFormat = QString("%1 %2").arg(mTimeFormat).arg(mDateFormat);
    else
        mClockFormat = mTimeFormat;

    mDateLabel->setVisible(mDateOnNewLine);

    updateMinWidth();

    // mDateFormat usually does not contain time portion, but since it's possible to use custom date format - it has to be supported. [Kuzma Shapran]
    int updateInterval = QString(mTimeFormat + " " + mDateFormat).replace(QRegExp("'[^']*'"),"").contains("s") ? 1000 : 60000;

    QDateTime now = currentDateTime();

    showTime(now);

    if (mClockTimer->interval() != updateInterval)
    {
        mClockTimer->setInterval(updateInterval);

        restartTimer(now);
    }
}
예제 #24
0
void ImageQualityController::highQualityRepaintTimerFired()
{
    if (m_renderView.documentBeingDestroyed())
        return;
    if (!m_animatedResizeIsActive && !m_liveResizeOptimizationIsActive)
        return;
    m_animatedResizeIsActive = false;

    // If the FrameView is in live resize, punt the timer and hold back for now.
    if (m_renderView.frameView().inLiveResize()) {
        restartTimer();
        return;
    }

    for (auto it = m_objectLayerSizeMap.begin(), end = m_objectLayerSizeMap.end(); it != end; ++it)
        it->key->repaint();

    m_liveResizeOptimizationIsActive = false;
}
void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityController>*)
{
    if (!m_animatedResizeIsActive && !m_liveResizeOptimizationIsActive)
        return;
    m_animatedResizeIsActive = false;

    for (ObjectLayerSizeMap::iterator it = m_objectLayerSizeMap.begin(); it != m_objectLayerSizeMap.end(); ++it) {
        if (Frame* frame = it->key->document()->frame()) {
            // If this renderer's containing FrameView is in live resize, punt the timer and hold back for now.
            if (frame->view() && frame->view()->inLiveResize()) {
                restartTimer();
                return;
            }
        }
        it->key->repaint();
    }

    m_liveResizeOptimizationIsActive = false;
}
예제 #26
0
void LxQtWorldClock::updateFormat()
{
    int timerInterval = 0;

    switch (mFormatType)
    {
    case FORMAT_CUSTOM:
    {
        mFormat = static_cast<Qt::DateFormat>(-1); // custom

        QString format = mCustomFormat;
        format.replace(QRegExp(QLatin1String("'[^']*'")), QString());
        if (format.contains(QLatin1String("SSS")))
            timerInterval = 1;
        else if (format.contains(QLatin1String("SS")))
            timerInterval = 10;
        else if (format.contains(QLatin1String("S")))
            timerInterval = 100;
        else if (format.contains(QLatin1String("s")))
            timerInterval = 1000;
        else
            timerInterval = 60000;
    }
        break;

    case FORMAT_LONG_TIMEONLY:
    case FORMAT_LONG:
        mFormat = Qt::DefaultLocaleLongDate;
        timerInterval = 1000;
        break;

    case FORMAT_SHORT_TIMEONLY:
    case FORMAT_SHORT:
        mFormat = Qt::DefaultLocaleShortDate;
        timerInterval = 60000;
        break;

    default:;
    }

    restartTimer(timerInterval);
}
예제 #27
0
KaduExtInfo::KaduExtInfo(bool migrate)
    :ExtInfo(extinfoPath("RExInfo.dat")), chatmenu(NULL), http(NULL), menuBirthday(false),menuNameDay(false)
{
    kdebugf();
    if (migrate)
    {
        extlist.loadFromFile(ggPath("RExInfo.dat"));
        extlist.saveToFile();
        MessageBox::msg(tr("ext_info v") + QString(EXTINFO_VERSION) + tr(" was imported settings from previous version."));
    }
    RegisterInConfigDialog(migrate);
    RegisterSignals();
    Create5ChatButton();
    onApplyConfigDialog();
    if (checkUpdateStable || checkUpdateUnstable)
        checkForNewVersion();
    connect(&timer, SIGNAL(timeout()), this, SLOT(checkAnniversary()));
    restartTimer();
    kdebugf2();
}
void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityController>*)
{
    if (!m_animatedResizeIsActive && !m_liveResizeOptimizationIsActive)
        return;
    m_animatedResizeIsActive = false;

    for (auto* layoutObject : m_objectLayerSizeMap.keys()) {
        if (LocalFrame* frame = layoutObject->document().frame()) {
            // If this layoutObject's containing FrameView is in live resize, punt the timer and hold back for now.
            if (frame->view() && frame->view()->inLiveResize()) {
                restartTimer();
                return;
            }
        }
        // TODO(wangxianzhu): Use LayoutObject::mutableForPainting().
        const_cast<LayoutObject*>(layoutObject)->setShouldDoFullPaintInvalidation();
    }

    m_liveResizeOptimizationIsActive = false;
}
void IdlenessWatcher::screenUnlocked(int exitCode, QProcess::ExitStatus exitStatus)
{

    mIsLocked = false;
    emit ActiveChanged(false);

    if (exitCode == 0)
    {
        restartTimer();
    }
    else
    {
        mErrorNotification.setSummary(tr("ERROR: Screen unlocked"));
        if (exitStatus == QProcess::NormalExit)
            mErrorNotification.setBody(tr("Locking program \"%1\" exited with error code %2").arg(mLockCommand).arg(exitCode));
        else
            mErrorNotification.setBody(tr("Locking program \"%1\" crashed with error code %2").arg(mLockCommand).arg(exitCode));
        mErrorNotification.update();
        mTimer.stop();
        connect(&mErrorNotification, SIGNAL(notificationClosed(CloseReason)), SLOT(idleTimeout()));
    }
}
void LLUpdaterServiceImpl::downloadError(std::string const & message)
{
    LL_INFOS("UpdaterService") << "Error downloading: " << message << LL_ENDL;

    mIsDownloading = false;

    // Restart the timer on error
    if(mIsChecking)
    {
        restartTimer(mCheckPeriod);
    }

    LLSD event;
    event["pump"] = LLUpdaterService::pumpName();
    LLSD payload;
    payload["type"] = LLSD(LLUpdaterService::DOWNLOAD_ERROR);
    payload["message"] = message;
    event["payload"] = payload;
    LLEventPumps::instance().obtain("mainlooprepeater").post(event);

    setState(LLUpdaterService::FAILURE);
}