JSModulesUnbundle::Module RAMBundleRegistry::getModule(
    uint32_t bundleId, uint32_t moduleId) {
  if (m_bundles.find(bundleId) == m_bundles.end()) {
    if (!m_factory) {
      throw std::runtime_error(
        "You need to register factory function in order to "
        "support multiple RAM bundles."
      );
    }

    auto bundlePath = m_bundlePaths.find(bundleId);
    if (bundlePath == m_bundlePaths.end()) {
      throw std::runtime_error(
        "In order to fetch RAM bundle from the registry, its file "
        "path needs to be registered first."
      );
    }
    m_bundles.emplace(bundleId, m_factory(bundlePath->second));
  }

  auto module = getBundle(bundleId)->getModule(moduleId);
  if (bundleId == MAIN_BUNDLE_ID) {
    return module;
  }
  return {
    folly::to<std::string>("seg-", bundleId, '_', std::move(module.name)),
    std::move(module.code),
  };
}
Esempio n. 2
0
void ReaderShim<ElemType>::Init(const ConfigParameters& config)
{
    intargvector numberOfuttsPerMinibatchForAllEpochs =
        config(L"nbruttsineachrecurrentiter", ConfigParameters::Array(intargvector(vector<int> { 1 })));

    bool prefetch = config(L"prefetch", true);
    // if prefetch - launching asynchronously,
    // otherwise deferring - synchronous execution during .get() call
    m_launchType = prefetch ? launch::async : launch::deferred;

    m_numParallelSequences = numberOfuttsPerMinibatchForAllEpochs[0];

    m_reader = m_factory(config);
    m_streams = m_reader->GetStreamDescriptions();
    for (auto i : m_streams)
    {
        m_nameToStreamId.insert(std::make_pair(i->m_name, i->m_id));
    }
}
Esempio n. 3
0
ConnectorBase * ConnectorInfo::create(Component* comp , const QString & name ,
                                      const QString & i18nName, const QPoint& pos) const
{
	Q_CHECK_PTR(m_factory);
	return m_factory(comp, name, i18nName, pos);
}	
KSimIoDevice * KSimIoDeviceInfo::create(const KSimIoDeviceInfo * info) const
{
	Q_CHECK_PTR(m_factory);
	return m_factory(info);
}	
void ParticleEmitter::createParticle(const sf::Vector2f& pos) {
  Particle* p = m_factory(this, pos);
  m_particles.push_back(p);
}