示例#1
0
void DependencyTree::resolve()
{
  resolvedList.clear();
  resolvingList.clear();
  ThreadPool threadPool;
  for (;;)
  {
    Resolvers resolvers;
    for (auto &&target : tree)
      resolve(target.first, resolvers);

    if (resolvers.empty() && resolvingList.empty() && threadPool.empty())
      return;

    std::string target;
    Resolver *resolver;
    time_t newestModificationTime;

    for (auto &&r : resolvers)
    {
      std::tie(target, resolver, newestModificationTime) = r;
      if (!isFileExist(target))
      {
        resolvingList.insert(target);
        threadPool.addJob([resolver]() { resolver->exec(); },
                          [this, target]() {
                            resolvingList.erase(target);
                            resolvedList.insert(target);
                          });
        continue;
      }
      auto time = getFileModification(target);
      if (time < newestModificationTime)
      {
        resolvingList.insert(target);
        threadPool.addJob([resolver]() { resolver->exec(); },
                          [this, target]() {
                            resolvingList.erase(target);
                            resolvedList.insert(target);
                          });
      }
      else
        resolvedList.insert(target);
    }
    threadPool.waitForOne();
  }
}
示例#2
0
ErrorCode MatchDocument(DocID doc_id, const char* doc_str) {

    // Uncomment if you're parallelising start query.
    /*tPool.barrierAll(START);
    pthread_mutex_lock(&querySort);
    if(sortQueries){
    	sortQueries = false;
    	sort(queries.begin(), queries.end(), queryCompare);
    }
    pthread_mutex_unlock(&querySort);*/

    static int n=0;

    char *icy = (char*)malloc(sizeof(char) * MAX_DOC_LENGTH);
    strcpy(icy, doc_str);

    int n1=queries.size();

    if(n!=n1) {

        for(int i=n; i<n1; i++) {
            Query_st x;

            x.query=queries[i];

            for(char *ph = strtok(queries[i].str," "); ph != NULL; ph=strtok(NULL," "))
                x.tokens.push_back(ph);

            query_hash.push_back(x);
            n=n1;
        }
    }

    MatchJob * job = new MatchJob(MatchDocument2, doc_id, icy);
    tPool.addJob(job);

    return EC_SUCCESS;
}
示例#3
0
void ProjectSaver::writeProjects (const OwnedArray<LibraryModule>& modules, const String& specifiedExporterToSave, bool isCommandLineApp)
{
    ThreadPool threadPool;

    // keep a copy of the basic generated files group, as each exporter may modify it.
    auto originalGeneratedGroup = generatedFilesGroup.state.createCopy();

    CLionProjectExporter* clionExporter = nullptr;
    OwnedArray<ProjectExporter> exporters;

    try
    {
        for (Project::ExporterIterator exp (project); exp.next();)
        {
            if (specifiedExporterToSave.isNotEmpty() && exp->getName() != specifiedExporterToSave)
                continue;

            auto* exporter = exporters.add (exp.exporter.release());

            exporter->initialiseDependencyPathValues();

            if (exporter->getTargetFolder().createDirectory())
            {
                if (exporter->isCLion())
                {
                    clionExporter = dynamic_cast<CLionProjectExporter*> (exporter);
                }
                else
                {
                    exporter->copyMainGroupFromProject();
                    exporter->settings = exporter->settings.createCopy();

                    exporter->addToExtraSearchPaths (RelativePath ("JuceLibraryCode", RelativePath::projectFolder));

                    generatedFilesGroup.state = originalGeneratedGroup.createCopy();
                    exporter->addSettingsForProjectType (project.getProjectType());

                    for (auto& module: modules)
                        module->addSettingsForModuleToExporter (*exporter, *this);

                    generatedFilesGroup.sortAlphabetically (true, true);
                    exporter->getAllGroups().add (generatedFilesGroup);
                }

                if (isCommandLineApp)
                    saveExporter (exporter, modules);
                else
                    threadPool.addJob (new ExporterJob (*this, exporter, modules), true);
            }
            else
            {
                addError ("Can't create folder: " + exporter->getTargetFolder().getFullPathName());
            }
        }
    }
    catch (ProjectExporter::SaveError& saveError)
    {
        addError (saveError.message);
    }

    if (! isCommandLineApp)
        while (threadPool.getNumJobs() > 0)
            Thread::sleep (10);

    if (clionExporter != nullptr)
    {
        for (auto* exporter : exporters)
            clionExporter->writeCMakeListsExporterSection (exporter);

        std::cout << "Finished saving: " << clionExporter->getName() << std::endl;
    }
}