Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"yiisoft/di": "^1.0",
"yiisoft/files": "^2.0",
"yiisoft/json": "^1.0",
"yiisoft/mutex": "^1.1",
"yiisoft/profiler": "^3.0",
"yiisoft/proxy": "^1.0.1",
"yiisoft/strings": "^2.2",
Expand Down
8 changes: 7 additions & 1 deletion src/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Yiisoft\Yii\Debug;

use Psr\Http\Message\ServerRequestInterface;
use Yiisoft\Mutex\Synchronizer;
use Yiisoft\Strings\WildcardPattern;
use Yiisoft\Yii\Console\Event\ApplicationStartup;
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
Expand All @@ -13,12 +14,15 @@

final class Debugger
{
public const SAVING_MUTEX_NAME = self::class;

private bool $skipCollect = false;
private bool $active = false;

public function __construct(
private DebuggerIdGenerator $idGenerator,
private StorageInterface $target,
private Synchronizer $synchronizer,
/**
* @var CollectorInterface[]
*/
Expand Down Expand Up @@ -64,7 +68,9 @@ public function shutdown(): void

try {
if (!$this->skipCollect) {
$this->target->flush();
$this->synchronizer->execute(self::SAVING_MUTEX_NAME . $this->idGenerator->getId(), function () {
$this->target->flush();
});
}
} finally {
foreach ($this->collectors as $collector) {
Expand Down