Compare commits
No commits in common. "main" and "v0.2.0" have entirely different histories.
2 changed files with 3 additions and 15 deletions
|
|
@ -23,7 +23,7 @@ namespace PlaytimeHistory;
|
||||||
public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
public class PlaytimeHistory : BasePlugin, IPluginConfig<PlaytimeHistoryConfig>
|
||||||
{
|
{
|
||||||
public override string ModuleName => "PlaytimeHistory";
|
public override string ModuleName => "PlaytimeHistory";
|
||||||
public override string ModuleVersion => "0.2.1";
|
public override string ModuleVersion => "0.2.0";
|
||||||
public override string ModuleAuthor => "astra";
|
public override string ModuleAuthor => "astra";
|
||||||
public override string ModuleDescription => "Records playtime per session, team and alive/dead state";
|
public override string ModuleDescription => "Records playtime per session, team and alive/dead state";
|
||||||
|
|
||||||
|
|
|
||||||
16
Writer.cs
16
Writer.cs
|
|
@ -38,9 +38,7 @@ public sealed class Writer
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kept here: a single-reader unbounded channel can't count itself (Reader.Count throws).
|
public int Queued => _queue.Reader.Count;
|
||||||
private int _queued;
|
|
||||||
public int Queued => Volatile.Read(ref _queued);
|
|
||||||
public int Spooled => _spooled;
|
public int Spooled => _spooled;
|
||||||
public bool Migrated => Volatile.Read(ref _migrated);
|
public bool Migrated => Volatile.Read(ref _migrated);
|
||||||
public bool Failing => Volatile.Read(ref _failing);
|
public bool Failing => Volatile.Read(ref _failing);
|
||||||
|
|
@ -50,11 +48,7 @@ public sealed class Writer
|
||||||
public void Start() => _loop = Task.Run(RunAsync);
|
public void Start() => _loop = Task.Run(RunAsync);
|
||||||
|
|
||||||
// From the game thread. Never blocks.
|
// From the game thread. Never blocks.
|
||||||
public void Enqueue(Op op)
|
public void Enqueue(Op op) => _queue.Writer.TryWrite(op);
|
||||||
{
|
|
||||||
if (_queue.Writer.TryWrite(op))
|
|
||||||
Interlocked.Increment(ref _queued);
|
|
||||||
}
|
|
||||||
|
|
||||||
// On unload: sends what's queued, waiting up to `timeout`, then spools anything left.
|
// On unload: sends what's queued, waiting up to `timeout`, then spools anything left.
|
||||||
public void Drain(TimeSpan timeout)
|
public void Drain(TimeSpan timeout)
|
||||||
|
|
@ -72,11 +66,8 @@ public sealed class Writer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (_queue.Reader.TryRead(out var op))
|
while (_queue.Reader.TryRead(out var op))
|
||||||
{
|
|
||||||
Interlocked.Decrement(ref _queued);
|
|
||||||
Spool(op);
|
Spool(op);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RunAsync()
|
private async Task RunAsync()
|
||||||
{
|
{
|
||||||
|
|
@ -96,10 +87,7 @@ public sealed class Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_queue.Reader.TryRead(out var op))
|
while (_queue.Reader.TryRead(out var op))
|
||||||
{
|
|
||||||
Interlocked.Decrement(ref _queued);
|
|
||||||
await HandleAsync(op, token);
|
await HandleAsync(op, token);
|
||||||
}
|
|
||||||
|
|
||||||
bool more;
|
bool more;
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue