Пример #1
0
Sender::Sender (Receiver *r, Disconnector *d)
    : QObject ()
{
    this->r = r; this->d = d;
    if (r)
        connect (this, SIGNAL(fired()), r, SLOT(received()));
    if (d)
        connect (this, SIGNAL(fired()), d, SLOT(received()));
};
Пример #2
0
NO_SANITIZE_ADDRESS
void TimerBase::runInternal() {
  if (!canFire())
    return;

  m_weakPtrFactory.revokeAll();

  TRACE_EVENT0("blink", "TimerBase::run");
#if DCHECK_IS_ON()
  DCHECK_EQ(m_thread, currentThread())
      << "Timer posted by " << m_location.function_name() << " "
      << m_location.file_name() << " was run on a different thread";
#endif

  if (m_repeatInterval) {
    double now = timerMonotonicallyIncreasingTime();
    // This computation should be drift free, and it will cope if we miss a
    // beat, which can easily happen if the thread is busy.  It will also cope
    // if we get called slightly before m_unalignedNextFireTime, which can
    // happen due to lack of timer precision.
    double intervalToNextFireTime =
        m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval);
    setNextFireTime(timerMonotonicallyIncreasingTime(), intervalToNextFireTime);
  } else {
    m_nextFireTime = 0;
  }
  fired();
}
Пример #3
0
void RunLoop::TimerBase::start(Seconds interval, bool repeating)
{
    LockHolder locker(m_runLoop->m_loopLock);
    stop(locker);
    m_scheduledTask = ScheduledTask::create([this] {
        fired();
    }, interval, repeating);
    m_runLoop->scheduleAndWakeUp(locker, *m_scheduledTask);
}
void Sender::fire ()
{
	::Step++;
	const int stepCopy = ::Step;
	TRACE (stepCopy, "Sender::fire()");
	Q_ASSERT (::Step == 1 || ::Step == 3);

	emit fired ();
	TRACE (stepCopy, "ends Sender::fire()");
}
Пример #5
0
void Sender::fire ()
{
    ::Step++;
    const int stepCopy = ::Step;
    TRACE (stepCopy, "Sender::fire()");
    if (::Step != 1 && ::Step != 3)
        qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);

    emit fired ();
    TRACE (stepCopy, "ends Sender::fire()");
}
void Disconnector::received ()
{
	::Step++;
	const int stepCopy = ::Step;
	TRACE (stepCopy, "Disconnector::received()");
	Q_ASSERT (::Step == 5 || ::Step == 6);

	fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
		(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
	if (sender () == 0)
		fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");

	if (::Step == 5)
	{
		disconnect (s, SIGNAL (fired ()), s->d, SLOT (received ()));

		connect (&RandomSender, SIGNAL (fired ()), s->d, SLOT (received ()));
	}

	TRACE (stepCopy, "ends Disconnector::received()");
}
Пример #7
0
void Disconnector::received ()
{
    ::Step++;
    const int stepCopy = ::Step;
    TRACE (stepCopy, "Disconnector::received()");
    if (::Step != 5 && ::Step != 6)
        qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);

    fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
        (const char *) objectName ().toLatin1 (), sender ()->metaObject()->className());
    if (sender () == 0)
        fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");

    if (::Step == 5)
    {
        disconnect (s, SIGNAL(fired()), s->d, SLOT(received()));

        connect (&RandomSender, SIGNAL(fired()), s->d, SLOT(received()));
    }

    TRACE (stepCopy, "ends Disconnector::received()");
}
static void setRepeatingTimer(struct nodeInstanceData *ctx, const VuoReal seconds, VuoOutputTrigger(fired,VuoInteger))
{
	if (ctx->timer)
		cancelRepeatingTimer(ctx);

	dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
	ctx->timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, q);

	uint64_t nanoseconds = seconds * NSEC_PER_SEC;
	dispatch_source_set_timer(ctx->timer, dispatch_time(DISPATCH_TIME_NOW, nanoseconds), nanoseconds, 0);
	dispatch_source_set_event_handler(ctx->timer, ^{
		fired(++ctx->eventCount);
	});
Пример #9
0
static void setRepeatingTimer(struct nodeInstanceData *ctx, const VuoReal seconds, VuoOutputTrigger(fired,void))
{
	cancelRepeatingTimer(ctx);

	if (seconds <= 0)
		return;

	dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
	ctx->timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, q);

	uint64_t nanoseconds = (seconds > 0.001 ? (seconds * NSEC_PER_SEC) : (NSEC_PER_SEC / 1000));
	dispatch_source_set_timer(ctx->timer, dispatch_time(DISPATCH_TIME_NOW, nanoseconds), nanoseconds, 0);
	dispatch_source_set_event_handler(ctx->timer, ^{
		fired();
	});
Пример #10
0
void RunLoop::TimerBase::timerFired()
{
    {
        LockHolder locker(m_runLoop->m_loopLock);

        if (!m_isActive)
            return;

        if (!m_isRepeating) {
            m_isActive = false;
            ::KillTimer(m_runLoop->m_runLoopMessageWindow, bitwise_cast<uintptr_t>(this));
        } else
            m_nextFireDate = MonotonicTime::now() + m_interval;
    }

    fired();
}
Пример #11
0
void KTimerJob::fire()
{
    if( !d->oneInstance || d->processes.isEmpty() ) {
        QProcess *proc = new QProcess;
        d->processes.append( proc );
        connect(proc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &KTimerJob::processExited);
        if (!d->command.simplified ().isEmpty()) {
	        proc->start(d->command);
	        emit fired( this );
        }
        if(proc->state() == QProcess::NotRunning) {
            const int i = d->processes.indexOf( proc);
            if (i != -1)
                delete d->processes.takeAt(i);
            emit error( this );
            emit finished( this, true );
        }
    }
}
Пример #12
0
NO_LAZY_SWEEP_SANITIZE_ADDRESS
void TimerBase::runInternal()
{
    if (!canFire())
        return;

    TRACE_EVENT0("blink", "TimerBase::run");
    ASSERT_WITH_MESSAGE(m_thread == currentThread(), "Timer posted by %s %s was run on a different thread", m_location.functionName(), m_location.fileName());
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "BlinkInternal");

    if (m_repeatInterval) {
        double now = monotonicallyIncreasingTime();
        // This computation should be drift free, and it will cope if we miss a beat,
        // which can easily happen if the thread is busy.  It will also cope if we get
        // called slightly before m_unalignedNextFireTime, which can happen due to lack
        // of timer precision.
        double intervalToNextFireTime = m_repeatInterval - fmod(now - m_nextFireTime, m_repeatInterval);
        setNextFireTime(monotonicallyIncreasingTime(), intervalToNextFireTime);
    } else {
        m_nextFireTime = 0;
    }
    fired();
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "Sleeping");
}
Пример #13
0
void RunLoop::TimerBase::start(double fireInterval, bool repeat)
{
    m_timerSource.scheduleAfterDelay("[WebKit] RunLoop::Timer", std::function<bool ()>([this, repeat] { fired(); return repeat; }),
        std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(fireInterval)), G_PRIORITY_DEFAULT, nullptr, m_runLoop.m_mainContext.get());
}