Ejemplo n.º 1
0
    void scheduleNext(std::list<Process*>& readyQueue, unsigned int tick) {
        // No work to do
        if (readyQueue.empty()) {
            executing = NULL;
            return;
        }
        // If there's nothing that was executing before (first run),
        // Grab the first process in the ready queue
        if (executing == NULL) {
            queueLoc = readyQueue.begin();
        }
        executing = *queueLoc;
        // Run the next scheduled process and increment wait times
        executing->run();
        incrWait(readyQueue, executing);
        // If executing process is done, remove it from the ready queue
        // safely
        if (executing->isDone()) {
            removeFromQueue(readyQueue, executing);
        }
        // Round robin, 'rotate' the queue
        else {
            rotateQueue(readyQueue);
        }
        return;

    }
Ejemplo n.º 2
0
	void RgAnalysisManager::handleAnalysed ()
	{
		const auto& result = CurrentAnalyser_->GetResult ();

		for (const auto& track : result.Tracks_)
		{
			const auto id = Coll_->FindTrack (track.TrackPath_);
			if (id == -1)
			{
				qWarning () << Q_FUNC_INFO
						<< "cannot find track"
						<< track.TrackPath_;
				continue;
			}

			Coll_->GetStorage ()->SetRgTrackInfo (id,
					{
						track.TrackGain_,
						track.TrackPeak_,
						result.AlbumGain_,
						result.AlbumPeak_
					});
		}

		CurrentAnalyser_.reset ();
		rotateQueue ();
	}
Ejemplo n.º 3
0
	void Checker::handleDiscoError ()
	{
		qDebug () << Q_FUNC_INFO
				<< Current_.Name_;
		Model_->MarkNoNews (Current_);

		rotateQueue ();
	}
Ejemplo n.º 4
0
	void Checker::handleDiscoReady ()
	{
		auto releases = qobject_cast<Media::IPendingDisco*> (sender ())->GetReleases ();
		releases.erase (std::remove_if (releases.begin (), releases.end (),
					[this] (const Media::ReleaseInfo& info)
					{
						return !Types_.contains (info.Type_);
					}),
				releases.end ());

		bool foundSome = false;

		for (const auto& albumPtr : Current_.Albums_)
		{
			const auto pos = std::find_if (releases.begin (), releases.end (),
					[&albumPtr] (const Media::ReleaseInfo& release)
					{
						return IsSameRelease (albumPtr, release);
					});

			if (pos == releases.end ())
				continue;

			releases.erase (pos);
			foundSome = true;
		}

		if (!foundSome)
		{
			qWarning () << Q_FUNC_INFO
					<< "we probably found something different for"
					<< Current_.Name_;
			for (const auto& release : releases)
				qWarning () << "\t" << release.Year_ << release.Name_;
			Model_->MarkNoNews (Current_);
		}
		else if (releases.isEmpty ())
			Model_->MarkNoNews (Current_);
		else
			Model_->SetMissingReleases (releases, Current_);

		rotateQueue ();
	}
Ejemplo n.º 5
0
	void RgAnalysisManager::handleScanFinished ()
	{
		qDebug () << Q_FUNC_INFO << IsScanAllowed ();
		if (!IsScanAllowed ())
			return;

		QSet<int> albums;
		for (const auto track : Coll_->GetStorage ()->GetOutdatedRgTracks ())
			albums << Coll_->GetTrackAlbumId (track);

		const bool wasEmpty = AlbumsQueue_.isEmpty ();

		for (auto albumId : albums)
			if (const auto& album = Coll_->GetAlbum (albumId))
				AlbumsQueue_ << album;

		qDebug () << AlbumsQueue_.size ()
				<< "albums to rescan";
		if (wasEmpty)
			rotateQueue ();
	}
Ejemplo n.º 6
0
	Checker::Checker (CheckModel *model,
			const QList<Media::ReleaseInfo::Type>& types,
			const ILMPProxy_ptr& lmpProxy,
			const ICoreProxy_ptr& coreProxy,
			QObject *parent)
	: QObject { parent }
	, Model_ { model }
	, Provider_ { coreProxy->GetPluginsManager ()->
				GetAllCastableTo<Media::IDiscographyProvider*> ().value (0) }
	, LmpProxy_ { lmpProxy }
	, Types_ { types }
	, Artists_ { Model_->GetSelectedArtists () }
	{
		if (!Provider_)
		{
			qWarning () << Q_FUNC_INFO
					<< "no providers :(";
			deleteLater ();
			return;
		}

		rotateQueue ();
	}
Ejemplo n.º 7
0
 // Ensure what's removed from the ready queue is isn't pointed
 // to after it's removed by rotating queueLoc beforehand
 void removeFromQueue(std::list<Process*>& readyQueue, Process* item) {
     if (item == (*queueLoc)) {
         rotateQueue(readyQueue);
     }
     readyQueue.remove(item);
 }