void
ScrobbleService::setConnection(PlayerConnection*c)
{
    if( m_connection )
    {
        // disconnect from all the objects that we connect to below
        disconnect( m_connection, 0, this, 0);
        if(m_watch)
            m_connection->setElapsed(m_watch->elapsed());
    }

    //
    connect(c, SIGNAL(trackStarted(Track, Track)), SLOT(onTrackStarted(Track, Track)));
    connect(c, SIGNAL(paused()), SLOT(onPaused()));
    connect(c, SIGNAL(resumed()), SLOT(onResumed()));
    connect(c, SIGNAL(stopped()), SLOT(onStopped()));

    connect(c, SIGNAL(trackStarted(Track, Track)), SIGNAL(trackStarted(Track, Track)));
    connect(c, SIGNAL(resumed()), SIGNAL(resumed()));
    connect(c, SIGNAL(paused()), SIGNAL(paused()));
    connect(c, SIGNAL(stopped()), SIGNAL(stopped()));
    connect(c, SIGNAL(bootstrapReady(QString)), SIGNAL( bootstrapReady(QString)));

    m_connection = c;

    if(c->state() == Playing || c->state() == Paused)
        c->forceTrackStarted(Track());

    if( c->state() == Paused )
        c->forcePaused();
}
Ejemplo n.º 2
0
void ForgettableWatcherBase::connectForwardedInterface()
{
    Q_D(ForgettableWatcherBase);
    connect(d, SIGNAL(started()), this, SIGNAL(started()));
    connect(d, SIGNAL(finished()), this, SLOT(deleteObject()));
    connect(d, SIGNAL(canceled()), this, SIGNAL(canceled()));
    connect(d, SIGNAL(paused()), this, SIGNAL(paused()));
    connect(d, SIGNAL(resumed()), this, SIGNAL(resumed()));
    connect(d, SIGNAL(resultReadyAt(int)), this, SIGNAL(resultReadyAt(int)));
    connect(d, SIGNAL(resultsReadyAt(int, int)), this, SIGNAL(resultsReadyAt(int, int)));
    connect(d, SIGNAL(progressRangeChanged(int, int)), this, SIGNAL(progressRangeChanged(int, int)));
    connect(d, SIGNAL(progressValueChanged(int)), this, SIGNAL(progressValueChanged(int)));
    connect(d, SIGNAL(progressTextChanged(const QString&)), this, SIGNAL(progressTextChanged(const QString&)));
}
Ejemplo n.º 3
0
void emitCreateCont(IRGS& env) {
  auto const resumeOffset = nextBcOff(env);
  assertx(!resumed(env));
  assertx(curFunc(env)->isGenerator());

  if (curFunc(env)->isAsyncGenerator()) PUNT(CreateCont-AsyncGenerator);

  // Create the Generator object. CreateCont takes care of copying local
  // variables and iterators.
  auto const func = curFunc(env);
  auto const resumeSk = SrcKey(func, resumeOffset, true);
  auto const bind_data = LdBindAddrData { resumeSk, invSPOff(env) + 1 };
  auto const resumeAddr = gen(env, LdBindAddr, bind_data);
  auto const cont =
    gen(env,
        CreateCont,
        fp(env),
        cns(env, func->numSlotsInFrame()),
        resumeAddr,
        cns(env, resumeOffset));

  // The suspend hook will decref the newly created generator if it throws.
  auto const contAR =
    gen(env,
        LdContActRec,
        IsAsyncData(curFunc(env)->isAsync()),
        cont);
  suspendHookE(env, fp(env), contAR, cont);

  // Grab caller info from ActRec, free ActRec, store the return value
  // and return control to the caller.
  gen(env, StRetVal, fp(env), cont);
  auto const ret_data = RetCtrlData { offsetToReturnSlot(env), false };
  gen(env, RetCtrl, ret_data, sp(env), fp(env));
}
Ejemplo n.º 4
0
void endInlinedCommon(IRGS& env) {
  assertx(!curFunc(env)->isPseudoMain());

  assertx(!resumed(env));

  decRefLocalsInline(env);
  decRefThis(env);

  gen(env, InlineReturn, fp(env));

  // Return to the caller function.  Careful between here and the
  // updateMarker() below, where the caller state isn't entirely set up.
  env.inlineLevel--;
  env.bcStateStack.pop_back();
  always_assert(env.bcStateStack.size() > 0);

  updateMarker(env);

  /*
   * After the end of inlining, we are restoring to a previously defined stack
   * that we know is entirely materialized (i.e. in memory), so stackDeficit
   * needs to be slammed to zero.
   *
   * The push of the return value in the caller of this function is not yet
   * materialized.
   */
  assertx(env.irb->evalStack().empty());
  env.irb->clearStackDeficit();

  FTRACE(1, "]]] end inlining: {}\n", curFunc(env)->fullName()->data());
}
Ejemplo n.º 5
0
void tearDownEagerAsyncFrame(ActRec*& fp, Stack& stack, PC& pc, ObjectData* e) {
  auto const func = fp->func();
  auto const prevFp = fp->sfp();
  auto const soff = fp->m_soff;
  assert(!fp->resumed());
  assert(func->isAsyncFunction());
  assert(*reinterpret_cast<const Op*>(pc) != OpRetC);

  FTRACE(1, "tearDownAsyncFrame: {} ({})\n  fp {} prevFp {}\n",
         func->fullName()->data(),
         func->unit()->filepath()->data(),
         implicit_cast<void*>(fp),
         implicit_cast<void*>(prevFp));

  try {
    frame_free_locals_unwind(fp, func->numLocals());
  } catch (...) {}

  stack.ndiscard(func->numSlotsInFrame());
  stack.ret();
  assert(stack.topTV() == &fp->m_r);
  tvWriteObject(c_StaticWaitHandle::CreateFailed(e), &fp->m_r);
  e->decRefCount();

  if (UNLIKELY(!prevFp)) {
    pc = 0;
    return;
  }

  assert(stack.isValidAddress(reinterpret_cast<uintptr_t>(prevFp)) ||
         prevFp->resumed());
  auto const prevOff = soff + prevFp->func()->base();
  pc = prevFp->func()->unit()->at(prevOff);
  fp = prevFp;
}
ScrobblesListWidget::ScrobblesListWidget( QWidget* parent )
    :QListWidget( parent ), m_trackItem( 0 )
{
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

#ifdef Q_OS_MAC
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) );
#endif

    setAttribute( Qt::WA_MacNoClickThrough );
    setAttribute( Qt::WA_MacShowFocusRect, false );

    setUniformItemSizes( false );
    setSortingEnabled( false );
    setSelectionMode( QAbstractItemView::NoSelection );
    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );

    connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)));

    connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );
    connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) );

    connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track)));
    connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused()));
    connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed()));
    connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped()));

    onSessionChanged( aApp->currentSession() );
}
Ejemplo n.º 7
0
void emitCreateCont(HTS& env) {
  auto const resumeOffset = nextBcOff(env);
  assert(!resumed(env));
  assert(curFunc(env)->isGenerator());

  if (curFunc(env)->isAsyncGenerator()) PUNT(CreateCont-AsyncGenerator);

  // Create the Generator object. CreateCont takes care of copying local
  // variables and iterators.
  auto const func = curFunc(env);
  auto const resumeSk = SrcKey(func, resumeOffset, true);
  auto const resumeAddr = gen(env, LdBindAddr, LdBindAddrData(resumeSk));
  auto const cont =
    gen(env,
        CreateCont,
        fp(env),
        cns(env, func->numSlotsInFrame()),
        resumeAddr,
        cns(env, resumeOffset));

  // The suspend hook will decref the newly created generator if it throws.
  auto const contAR = gen(env, LdContActRec, cont);
  suspendHookE(env, fp(env), contAR);

  // Grab caller info from ActRec, free ActRec, store the return value
  // and return control to the caller.
  gen(env, StRetVal, fp(env), cont);
  auto const retAddr = gen(env, LdRetAddr, fp(env));
  auto const stack = gen(env, RetAdjustStack, fp(env));
  auto const frame = gen(env, FreeActRec, fp(env));
  gen(env, RetCtrl, RetCtrlData(false), stack, frame, retAddr);
}
Ejemplo n.º 8
0
Scrobbler::Scrobbler( QObject* parent )
    : QObject( parent )
    , m_reachedScrobblePoint( false )
{
    connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ),
                                        SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection );

    connect( Tomahawk::InfoSystem::InfoSystem::instance(),
             SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
             SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );

    connect( AudioEngine::instance(), SIGNAL( started( const Tomahawk::result_ptr& ) ),
             SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection );

    connect( AudioEngine::instance(), SIGNAL( paused() ),
             SLOT( trackPaused() ), Qt::QueuedConnection );

    connect( AudioEngine::instance(), SIGNAL( resumed() ),
             SLOT( trackResumed() ), Qt::QueuedConnection );

    connect( AudioEngine::instance(), SIGNAL( stopped() ),
             SLOT( trackStopped() ), Qt::QueuedConnection );

    connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
}
Ejemplo n.º 9
0
void emitRetV(IRGS& env) {
  assertx(!resumed(env));
  assertx(!curFunc(env)->isResumable());
  if (isInlining(env)) {
    retFromInlined(env);
  } else {
    implRet(env);
  }
}
Ejemplo n.º 10
0
void 
workerService_t::onContinue(void)
{
	m_log->info("Received resume request, resuming service service.");
	setState(QSERVICE_RESUME);
	reportStatus(SERVICE_RUNNING);
	emit resumed();
	return;
}
Ejemplo n.º 11
0
void emitRetV(HTS& env) {
  assert(!resumed(env));
  assert(!curFunc(env)->isResumable());
  if (isInlining(env)) {
    retFromInlined(env, Type::BoxedInitCell);
  } else {
    implRet(env, Type::BoxedInitCell);
  }
}
Ejemplo n.º 12
0
bool SSTask::resume()
{
	if(!m_isWaiting)
		return false;
	m_isWaiting = false;
	waitCondition.wakeOne();
	if(isRunning())
		emit resumed();
	return true;
}
Ejemplo n.º 13
0
void emitRetC(IRGS& env) {
  if (curFunc(env)->isAsyncGenerator()) PUNT(RetC-AsyncGenerator);

  if (isInlining(env)) {
    assertx(!resumed(env));
    retFromInlined(env);
  } else {
    implRet(env);
  }
}
Ejemplo n.º 14
0
void 
controllerService_t::onContinue(void)
{
	m_log->info("Received resume request, resuming service service.");
	reportStatus(SERVICE_START_PENDING);
	setState(QSERVICE_STARTING);
	reportStatus(SERVICE_RUNNING);
	emit resumed();
	return;
}
Ejemplo n.º 15
0
void Timer::
resume()
{
    assert(m_state == TimerState::Suspended);
    assert(!m_timer.isActive());

    m_timer.start();
    changeState(TimerState::Running);

    Q_EMIT resumed();
}
VESPERSEnergyScanActionController::VESPERSEnergyScanActionController(VESPERSEnergyScanConfiguration *configuration, QObject *parent)
	: AMStepScanActionController(configuration, parent), VESPERSScanController(configuration)
{
	configuration_ = configuration;

	scan_ = new AMXASScan();
	scan_->setName(configuration_->name());
	scan_->setScanConfiguration(configuration_);
	scan_->setFileFormat("amCDFv1");
	scan_->setIndexType("fileSystem");
	scan_->setNotes(buildNotes());
	scan_->rawData()->addScanAxis(AMAxisInfo("eV", 0, "Incident Energy", "eV"));

	useFeedback_ = true;
	originalEnergy_ = VESPERSBeamline::vespers()->mono()->energy();

	AMControlInfoList list;
	list.append(VESPERSBeamline::vespers()->energy()->toInfo());
	configuration_->setAxisControlInfos(list);

	AMDetectorInfoSet detectors;
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("SplitIonChamber")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("PreKBIonChamber")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("MiniIonChamber")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("PostIonChamber")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("EnergySetpoint")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("MasterDwellTime")->toInfo());
	detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("RingCurrent")->toInfo());

	VESPERS::CCDDetectors ccdDetector = configuration_->ccdDetector();

	if (ccdDetector.testFlag(VESPERS::Roper))
		detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("RoperFileNumber")->toInfo());

	if (ccdDetector.testFlag(VESPERS::Mar))
		detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("MarFileNumber")->toInfo());

	if (ccdDetector.testFlag(VESPERS::Pilatus))
		detectors.addDetectorInfo(VESPERSBeamline::vespers()->exposedDetectorByName("PilatusFileNumber")->toInfo());

	configuration_->setDetectorConfigurations(detectors);

	secondsElapsed_ = 0;
	secondsTotal_ = configuration_->totalTime();
	elapsedTime_.setInterval(1000);
	connect(this, SIGNAL(started()), &elapsedTime_, SLOT(start()));
	connect(this, SIGNAL(cancelled()), &elapsedTime_, SLOT(stop()));
	connect(this, SIGNAL(paused()), &elapsedTime_, SLOT(stop()));
	connect(this, SIGNAL(resumed()), &elapsedTime_, SLOT(start()));
	connect(this, SIGNAL(failed()), &elapsedTime_, SLOT(stop()));
	connect(this, SIGNAL(finished()), &elapsedTime_, SLOT(stop()));
	connect(&elapsedTime_, SIGNAL(timeout()), this, SLOT(onScanTimerUpdate()));
}
Ejemplo n.º 17
0
void SimplyControllable::setSuspended(bool suspended)
{
    if(m_suspended != suspended) {
        m_suspended = suspended;
        if(m_suspended) {
            emit this->suspended();
        }
        else {
            emit resumed();
        }
    }
}
Ejemplo n.º 18
0
//----------------------------------------------------------------------------
ctkExampleDicomHost::ctkExampleDicomHost(ctkHostedAppPlaceholderWidget* placeholderWidget, int hostPort, int appPort) :
    ctkDicomAbstractHost(hostPort, appPort),
    PlaceholderWidget(placeholderWidget),
    exitingApplication(false)
{
  connect(this,SIGNAL(appReady()),SLOT(onAppReady()));
  connect(this,SIGNAL(startProgress()),this,SLOT(onStartProgress()));
  connect(this,SIGNAL(releaseAvailableResources()),this,SLOT(onReleaseAvailableResources()));
  connect(this,SIGNAL(resumed()),this,SLOT(onResumed()));
  connect(this,SIGNAL(completed()),this,SLOT(onCompleted()));
  connect(this,SIGNAL(suspended()),this,SLOT(onSuspended()));
  connect(this,SIGNAL(canceled()),this,SLOT(onCanceled()));
  connect(this,SIGNAL(exited()),this,SLOT(onExited()));
}
Ejemplo n.º 19
0
bool KJob::resume()
{
    Q_D(KJob);
    if ( d->suspended )
    {
        if ( doResume() )
        {
            d->suspended = false;
            emit resumed(this);

            return true;
        }
    }

    return false;
}
Ejemplo n.º 20
0
void AVClock::pause(bool p)
{
    if (clock_type != ExternalClock)
        return;
    if (p) {
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        timer.invalidate();
#else
        timer.stop();
#endif //QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        emit paused();
    } else {
        timer.start();
        emit resumed();
    }
    emit paused(p);
}
Ejemplo n.º 21
0
TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
    : QSystemTrayIcon( parent )
    , m_currentAnimationFrame( 0 )
    , m_showWindowAction( 0 )
{
    QIcon icon( RESPATH "icons/tomahawk-icon-128x128.png" );
    setIcon( icon );

    refreshToolTip();

    m_contextMenu = new QMenu();
    setContextMenu( m_contextMenu );

    ActionCollection *ac = ActionCollection::instance();
    m_contextMenu->addAction( ac->getAction( "playPause" ) );
    m_contextMenu->addAction( ac->getAction( "stop" ) );
    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ac->getAction( "previousTrack" ) );
    m_contextMenu->addAction( ac->getAction( "nextTrack" ) );
    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );

#ifdef Q_WS_MAC
    // On mac you can close the windows while leaving the app open. We then need a way to show the main window again
    m_contextMenu->addSeparator();
    m_showWindowAction = m_contextMenu->addAction( tr( "Hide Tomahawk Window" ) );
    m_showWindowAction->setData( true );
    connect( m_showWindowAction, SIGNAL( triggered() ), this, SLOT( showWindow() ) );
#endif

    m_contextMenu->addSeparator();
    m_contextMenu->addAction( ac->getAction( "quit" ) );

    connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) );
    connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( enablePause() ) );
    connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( enablePause() ) );
    connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( enablePlay() ) );
    connect( AudioEngine::instance(), SIGNAL( paused() ),  this, SLOT( enablePlay() ) );

    connect( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) );
    connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) );

    show();
}
Ejemplo n.º 22
0
void
ScrobbleService::onResumed()
{
    // We can sometimes get a stopped before a play when the
    // media player is playing before the scrobbler is started
    if ( state == Unknown ) return;

    state = Playing;

    Q_ASSERT(m_watch);
    Q_ASSERT(m_connection);

    //m_currentTrack.updateNowPlaying( m_currentTrack.duration() - (m_watch->elapsed()/1000) );

    if (m_watch)
        m_watch->resume();

    emit resumed();
}
VESPERSEnergyDacqScanController::VESPERSEnergyDacqScanController(VESPERSEnergyScanConfiguration *cfg, QObject *parent)
    : AMDacqScanController(cfg, parent), VESPERSScanController(cfg)
{
    config_ = cfg;

    secondsElapsed_ = 0;
    secondsTotal_ = config_->totalTime();
    elapsedTime_.setInterval(1000);
    connect(this, SIGNAL(started()), &elapsedTime_, SLOT(start()));
    connect(this, SIGNAL(cancelled()), &elapsedTime_, SLOT(stop()));
    connect(this, SIGNAL(paused()), &elapsedTime_, SLOT(stop()));
    connect(this, SIGNAL(resumed()), &elapsedTime_, SLOT(start()));
    connect(this, SIGNAL(failed()), &elapsedTime_, SLOT(stop()));
    connect(this, SIGNAL(finished()), &elapsedTime_, SLOT(stop()));
    connect(&elapsedTime_, SIGNAL(timeout()), this, SLOT(onScanTimerUpdate()));

    scan_ = new AMXASScan(); 	// MB: Moved from line 363 in startImplementation.
    scan_->setName(config_->name());
    scan_->setScanConfiguration(config_);
    scan_->setRunId(AMUser::user()->currentRunId());
    scan_->setIndexType("fileSystem");
    scan_->setFilePath(AMUserSettings::defaultRelativePathForScan(QDateTime::currentDateTime())+".cdf");
    scan_->setFileFormat("amCDFv1");
    scan_->replaceRawDataStore(new AMCDFDataStore(AMUserSettings::userDataFolder % scan_->filePath(), false));
    scan_->rawData()->addScanAxis(AMAxisInfo("eV", 0, "Incident Energy", "eV"));

    scan_->setNotes(buildNotes());

    AMOldDetectorSet *ionChambers = VESPERSBeamline::vespers()->ionChambers();
    AMMeasurementInfo temp = AMMeasurementInfo("", "");

    for (int i = 0; i < ionChambers->count(); i++) {

        temp = AMMeasurementInfo(*(ionChambers->detectorAt(i)->toInfo()));
        temp.name = ionChambers->detectorAt(i)->detectorName();
        scan_->rawData()->addMeasurement(temp);
        scan_->addRawDataSource(new AMRawDataSource(scan_->rawData(), scan_->rawData()->measurementCount() - 1), true, false);
    }

    addExtraDatasources();
    useDwellTimes(VESPERSBeamline::vespers()->dwellTimeTrigger(), VESPERSBeamline::vespers()->dwellTimeConfirmed());
}
Ejemplo n.º 24
0
void emitAwait(HTS& env, int32_t numIters) {
  auto const resumeOffset = nextBcOff(env);
  assert(curFunc(env)->isAsync());

  if (curFunc(env)->isAsyncGenerator()) PUNT(Await-AsyncGenerator);

  auto const exitSlow   = makeExitSlow(env);

  if (!topC(env)->isA(Type::Obj)) PUNT(Await-NonObject);

  auto const child = popC(env);
  gen(env, JmpZero, exitSlow, gen(env, IsWaitHandle, child));

  // cns() would ODR-use these
  auto const kSucceeded = c_WaitHandle::STATE_SUCCEEDED;
  auto const kFailed    = c_WaitHandle::STATE_FAILED;

  auto const state = gen(env, LdWHState, child);
  auto const failed = gen(env, EqInt, state, cns(env, kFailed));
  gen(env, JmpNZero, exitSlow, failed);

  env.irb->ifThenElse(
    [&] (Block* taken) {
      auto const succeeded = gen(env, EqInt, state, cns(env, kSucceeded));
      gen(env, JmpNZero, taken, succeeded);
    },
    [&] { // Next: the wait handle is not finished, we need to suspend
      if (resumed(env)) {
        implAwaitR(env, child, resumeOffset);
      } else {
        implAwaitE(env, child, resumeOffset, numIters);
      }
    },
    [&] { // Taken: retrieve the result from the wait handle
      auto const res = gen(env, LdWHResult, child);
      gen(env, IncRef, res);
      gen(env, DecRef, child);
      push(env, res);
    }
  );
}
Ejemplo n.º 25
0
void emitYieldK(IRGS& env) {
  auto const resumeOffset = nextBcOff(env);
  assertx(resumed(env));
  assertx(curFunc(env)->isGenerator());

  if (curFunc(env)->isAsyncGenerator()) PUNT(YieldK-AsyncGenerator);

  yieldImpl(env, resumeOffset);

  auto const newKey = popC(env);
  auto const oldKey = gen(env, LdContArKey, TCell, fp(env));
  gen(env, StContArKey, fp(env), newKey);
  gen(env, DecRef, oldKey);

  auto const keyType = newKey->type();
  if (keyType <= TInt) {
    gen(env, ContArUpdateIdx, fp(env), newKey);
  }

  yieldReturnControl(env);
}
Ejemplo n.º 26
0
void emitYield(IRGS& env) {
  auto const resumeOffset = nextBcOff(env);
  assertx(resumed(env));
  assertx(curFunc(env)->isGenerator());

  if (curFunc(env)->isAsyncGenerator()) PUNT(Yield-AsyncGenerator);

  yieldImpl(env, resumeOffset);

  // take a fast path if this generator has no yield k => v;
  if (curFunc(env)->isPairGenerator()) {
    auto const newIdx = gen(env, ContArIncIdx, fp(env));
    auto const oldKey = gen(env, LdContArKey, TCell, fp(env));
    gen(env, StContArKey, fp(env), newIdx);
    gen(env, DecRef, oldKey);
  } else {
    // we're guaranteed that the key is an int
    gen(env, ContArIncKey, fp(env));
  }

  yieldReturnControl(env);
}
Ejemplo n.º 27
0
void endInlinedCommon(HTS& env) {
  assert(!env.fpiActiveStack.empty());
  assert(!curFunc(env)->isPseudoMain());

  assert(!resumed(env));

  decRefLocalsInline(env);
  if (curFunc(env)->mayHaveThis()) {
    gen(env, DecRefThis, fp(env));
  }

  /*
   * Pop the ActRec and restore the stack and frame pointers.  It's
   * important that this does endInlining before pushing the return
   * value so stack offsets are properly tracked.
   */
  gen(env, InlineReturn, fp(env));

  // Return to the caller function.  Careful between here and the
  // updateMarker() below, where the caller state isn't entirely set up.
  env.bcStateStack.pop_back();
  env.fpiActiveStack.pop();

  updateMarker(env);
  gen(env, ResetSP, StackOffset{env.irb->spOffset()}, fp(env));

  /*
   * After the end of inlining, we are restoring to a previously defined stack
   * that we know is entirely materialized (i.e. in memory), so stackDeficit
   * needs to be slammed to zero.
   *
   * The push of the return value in the caller of this function is not yet
   * materialized.
   */
  assert(env.irb->evalStack().empty());
  env.irb->clearStackDeficit();

  FTRACE(1, "]]] end inlining: {}\n", curFunc(env)->fullName()->data());
}
Ejemplo n.º 28
0
void Stopwatch::clientMessage(QJsonObject msg, int id)
{
    if(msg.contains("start")){
        start(false);
        emit started();
        sendMsgButNotTo(msg,id,true);
    }
    if(msg.contains("stop")){
        stop(false);
        emit stoped();
        sendMsgButNotTo(msg,id,true);
    }
    if(msg.contains("resume")){
        resume(false);
        emit resumed();
        sendMsgButNotTo(msg,id,true);
    }
    if(msg.contains("set")){
        setTo((long)msg.value("set").toDouble(),false);
        emit timeSet();
        sendMsgButNotTo(msg,id,true);
    }
}
Ejemplo n.º 29
0
//remember last value because we don't reset  pts_, pts_v, delay_
void AVClock::pause(bool p)
{
    if (isPaused() == p)
        return;
    if (clock_type == AudioClock)
        return;
    m_state = p ? kPaused : kRunning;
    if (p) {
        QTimer::singleShot(0, this, SLOT(stopCorrectionTimer()));
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        timer.invalidate();
#else
        timer.stop();
#endif //QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        emit paused();
    } else {
        timer.start();
        QTimer::singleShot(0, this, SLOT(restartCorrectionTimer()));
        emit resumed();
    }
    t = QDateTime::currentMSecsSinceEpoch();
    emit paused(p);
}
Ejemplo n.º 30
0
DownloadManager::DownloadManager(const QString &url, QString const & filename,
                                 QString const & title, QWidget *parent):
    QWidget( parent ), m_downloadManager( new Download ),
    m_buttonCancel( new QPushButton("Cancel")), m_buttonPause( new QPushButton( "Pause") ),
    m_buttonResume( new QPushButton("Resume") ), m_progressBar( new QProgressBar ),
    m_gLayout( new QGridLayout )
{
    m_progressBar->setRange( 1, 100 );
    m_gLayout->addWidget( new QLabel(title), 0, 0 );
    m_gLayout->addWidget( m_progressBar, 1, 0 );
    m_gLayout->addWidget( m_buttonPause, 1, 1 );
    m_gLayout->addWidget( m_buttonResume, 1, 2 );
    m_gLayout->addWidget( m_buttonCancel, 1, 3 );
    m_downloadManager->download( url, filename );

    QObject::connect( m_downloadManager , SIGNAL(downloadProgress(int)),
                      m_progressBar, SLOT(setValue(int)) );
    QObject::connect( m_buttonPause, SIGNAL(clicked()), this, SLOT( paused()) );
    QObject::connect( m_buttonCancel, SIGNAL(clicked()), this, SLOT(cancelled()) );
    QObject::connect( m_buttonResume, SIGNAL(clicked()), this, SLOT(resumed()) );
    QObject::connect( m_downloadManager, SIGNAL(downloadComplete()), this, SLOT(downloadCompleted()) );
    setLayout( m_gLayout );
}