void UnitTest::finishCase () { if (m_case != nullptr) { // If this goes off it means you forgot to // report any passing test case items! // bassert (m_case->items.size () > 0); m_case->secondsElapsed = RelativeTime ( Time::getCurrentTime () - m_case->whenStarted).inSeconds (); m_suite->tests += m_case->items.size (); m_suite->failures += m_case->failures; m_suite->cases.add (m_case.release ()); } }
void SliderBank::mouseDown (const MouseEvent& event) { if (event.eventTime - prevMouseDownTime < RelativeTime(MicronSlider::doubleClickDuration)) { // double-click, initiate default-values painting resettingValuesToDefault = true; resetDoubleClickTimer(); } else { // first click, prime for double-click detection prevMouseDownTime = event.eventTime; } // possibly lock onto a particular slider for dragging. if (event.mods.isRightButtonDown() || ! broadStrokesEnabled) lockedSliderBeingDragged = findSliderAtPos(event.getPosition()); // let mouseDrag work out which slider to click and manage tracking from there. mouseDrag(event); }
// Fetch the validators from a source and process the result // void fetchAndProcessSource (SourceInfo& sourceInfo) { Array <Validator::Info> newInfo = sourceInfo.source->fetch (); if (newInfo.size () != 0) { sourceInfo.status = SourceInfo::statusFetched; sourceInfo.whenToFetch = Time::getCurrentTime () + RelativeTime (hoursBetweenFetches * 60.0 * 60.0); Validator::List::Ptr newList (createListFromInfo (newInfo)); compareLists (*sourceInfo.list, *newList, *this); sourceInfo.list = newList; } else { // Failed to fetch, don't update fetch time sourceInfo.status = SourceInfo::statusFailed; sourceInfo.numberOfFailures++; } }
void threadRun () { while (! m_shouldStop) { Time const currentTime = Time::getCurrentTime (); double seconds = 0; { LockType::ScopedLockType lock (m_mutex); // Notify everyone whose timer has expired // if (! m_items.empty ()) { for (;;) { Items::iterator const iter = m_items.begin (); // Has this timer expired? if (iter->m_notificationTime <= currentTime) { // Yes, so call the listener. // // Note that this happens while the lock is held. // iter->m_listener->onDeadlineTimer (*iter); // Remove it from the list. m_items.erase (iter); // Is the timer recurring? if (iter->m_secondsRecurring > 0) { // Yes so set the timer again. iter->m_notificationTime = currentTime + RelativeTime (iter->m_secondsRecurring); // Keep it active. insertSorted (*iter); } else { // Not a recurring timer, deactivate it. iter->m_isActive = false; } } else { break; } } } // Figure out how long we need to wait. // This has to be done while holding the lock. // if (! m_items.empty ()) { seconds = (m_items.front ().m_notificationTime - currentTime).inSeconds (); } else { seconds = 0; } } // Note that we have released the lock here. // if (seconds > 0) { // Wait until interrupt or next timer. // m_thread.wait (static_cast <int> (seconds * 1000 + 0.5)); } else if (seconds == 0) { // Wait until interrupt // m_thread.wait (); } else { // Do not wait. This can happen if the recurring timer duration // is extremely short, or if a listener wastes too much time in // their callback. } } }
RelativeTime RelativeTime::days (const RelativeTime::value_type numberOfDays) noexcept { return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0)); }
RelativeTime RelativeTime::minutes (const RelativeTime::value_type numberOfMinutes) noexcept { return RelativeTime (numberOfMinutes * 60.0); }
RelativeTime RelativeTime::milliseconds (const std::int64_t milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); }
RelativeTime RelativeTime::weeks (const double numberOfWeeks) noexcept { return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0)); }
RelativeTime RelativeTime::hours (const double numberOfHours) noexcept { return RelativeTime (numberOfHours * (60.0 * 60.0)); }
const RelativeTime RelativeTime::operator- (const double secondsToSubtract) const throw() { return RelativeTime (seconds - secondsToSubtract); }
const RelativeTime RelativeTime::operator+ (const double secondsToAdd) const throw() { return RelativeTime (seconds + secondsToAdd); }
const RelativeTime RelativeTime::operator- (const RelativeTime& timeToSubtract) const throw() { return RelativeTime (seconds - timeToSubtract.seconds); }
//============================================================================== const RelativeTime RelativeTime::operator+ (const RelativeTime& timeToAdd) const throw() { return RelativeTime (seconds + timeToAdd.seconds); }
void SliderBank::resetDoubleClickTimer() { // ensure next click does not look like another double-click prevMouseDownTime = Time::getCurrentTime() - RelativeTime(MicronSlider::doubleClickDuration + 1.0); }
const RelativeTime RelativeTime::milliseconds (const int64 milliseconds) noexcept { return RelativeTime (milliseconds * 0.001); }
RelativeTime RelativeTime::minutes (const double numberOfMinutes) noexcept { return RelativeTime (numberOfMinutes * 60.0); }
const RelativeTime RelativeTime::milliseconds (const int64 milliseconds) throw() { return RelativeTime (milliseconds * 0.001); }
RelativeTime RelativeTime::days (const double numberOfDays) noexcept { return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0)); }
const RelativeTime RelativeTime::minutes (const double numberOfMinutes) throw() { return RelativeTime (numberOfMinutes * 60.0); }
RelativeTime RelativeTime::fromStartup () { return RelativeTime ( detail::monotonicCurrentTimeInSeconds() - detail::getStartupTime()); }
const RelativeTime RelativeTime::hours (const double numberOfHours) throw() { return RelativeTime (numberOfHours * (60.0 * 60.0)); }
RelativeTime RelativeTime::seconds (RelativeTime::value_type s) noexcept { return RelativeTime (s); }
const RelativeTime RelativeTime::days (const double numberOfDays) throw() { return RelativeTime (numberOfDays * (60.0 * 60.0 * 24.0)); }
RelativeTime RelativeTime::hours (const RelativeTime::value_type numberOfHours) noexcept { return RelativeTime (numberOfHours * (60.0 * 60.0)); }
const RelativeTime RelativeTime::weeks (const double numberOfWeeks) throw() { return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0)); }
RelativeTime RelativeTime::weeks (const RelativeTime::value_type numberOfWeeks) noexcept { return RelativeTime (numberOfWeeks * (60.0 * 60.0 * 24.0 * 7.0)); }
RelativeTime RelativeTime::seconds (double s) noexcept { return RelativeTime (s); }