Пример #1
0
void setExecutor(
    std::shared_ptr<Exe> executor,
    Singleton<std::weak_ptr<Exe>>& sExecutor,
    Singleton<RWSpinLock, LockTag>& sExecutorLock) {
  RWSpinLock::WriteHolder guard(sExecutorLock.get());
  *sExecutor.get() = std::move(executor);
}
Пример #2
0
std::shared_ptr<Exe> getExecutor(
    Singleton<std::weak_ptr<Exe>>& sExecutor,
    Singleton<std::shared_ptr<DefaultExe>>& sDefaultExecutor,
    Singleton<RWSpinLock, LockTag>& sExecutorLock) {
  std::shared_ptr<Exe> executor;
  auto singleton = sExecutor.get();
  auto lock = sExecutorLock.get();

  {
    RWSpinLock::ReadHolder guard(lock);
    if ((executor = sExecutor->lock())) {
      return executor;
    }
  }


  RWSpinLock::WriteHolder guard(lock);
  executor = singleton->lock();
  if (!executor) {
    executor = *sDefaultExecutor.get();
    *singleton = executor;
  }
  return executor;
}
Пример #3
0
FormatRegistry& FormatRegistry::instance()
{
    static Singleton<FormatRegistry> sh;
    return *sh.get();
}
Пример #4
0
TestRunner& TestRunner::getDefault()
{
    return *singleton.get();
}
Пример #5
0
Houses* Houses::getInstance()
{
  static Singleton<Houses> instance;
  return instance.get();
}
Пример #6
0
GarbageCollector& GarbageCollector::instance() 
{
	return *singleton.get();
}
Пример #7
0
IOPlayer* IOPlayer::instance()
{
	static Singleton<IOPlayer> instance;
	return instance.get();
}
Пример #8
0
ConnectionManager* ConnectionManager::getInstance()
{
	static Singleton<ConnectionManager> instance;
	return instance.get();
}