protected function createAndCache($what)
 {
     if (null !== $this->{$what}) {
         return $this->{$what};
     }
     $cacheClass = $this->options["{$what}_cache_class"];
     if (null === $this->options['cache_dir'] || null === $cacheClass) {
         return $this->{$what} = new $this->options["{$what}_class"]($this->getRouteCollection(), $this->context);
     }
     $cache = new ExpirableConfigCache($this->options['cache_dir'] . '/' . $cacheClass . '.php', $this->options['debug'], $this->metaQuery->getLastTouched());
     if (!$cache->isFresh()) {
         $cs = new CriticalSection();
         $cs->setLogger($this->logger);
         $self = $this;
         $cs->execute(__FILE__, function () use($what, $self, $cache) {
             if (!$cache->isFresh()) {
                 $self->dumpIntoCache($cache, $what);
             } else {
                 $self->debug("Cache has been refreshed while we were waiting.");
             }
         });
     }
     if (!class_exists($cacheClass)) {
         require $cache->getPath();
     }
     return $this->{$what} = new $cacheClass($this->context);
 }
 /**
  *  This ensures that the critical section is re-entrant as documented.
  */
 public function testCallbackCanAcquireSameLockAgain()
 {
     $this->criticalSection->execute(__DIR__ . '/my/virtual/file1', function () {
         $this->criticalSection->execute(__DIR__ . '/my/virtual/file1', $this->createCallbackThatMustBeInvoked());
     });
 }