• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DemoBytom / DemoEngine / 19003713278

01 Nov 2025 10:41PM UTC coverage: 26.251% (+13.3%) from 12.934%
19003713278

push

coveralls.net

DemoBytom
Try out GitHubActions summary

530 of 2019 relevant lines covered (26.25%)

0.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Demo.Engine.Core/Features/StaThread/StaThreadWriter.cs
1
// Copyright © Michał Dembski and contributors.
2
// Distributed under MIT license. See LICENSE file in the root for more information.
3

4
using System.Threading.Channels;
5
using Demo.Engine.Core.ValueObjects;
6
using Microsoft.Extensions.ObjectPool;
7

8
namespace Demo.Engine.Core.Features.StaThread;
9

10
internal sealed class StaThreadWriter(
×
11
    ChannelWriter<StaThreadRequests> channelWriter,
×
12
    ObjectPool<StaThreadRequests.DoEventsOkRequest> doEventsOkPool)
×
13
    : IStaThreadWriter,
14
      IDisposable
15
{
16
    private readonly ChannelWriter<StaThreadRequests> _channelWriter = channelWriter;
×
17
    private readonly ObjectPool<StaThreadRequests.DoEventsOkRequest> _doEventsOkPool = doEventsOkPool;
×
18
    private bool _disposedValue;
19

20
    public async Task<RenderingSurfaceId> CreateSurface(
21
        CancellationToken cancellationToken = default)
22
    {
23
        var createSurfaceRequest = StaThreadRequests.CreateSurface();
×
24
        await _channelWriter.WriteAsync(
×
25
                createSurfaceRequest,
×
26
                cancellationToken);
×
27

28
        return await createSurfaceRequest.Invoked;
×
29
    }
×
30

31
    public async ValueTask<bool> DoEventsOk(
32
        RenderingSurfaceId renderingSurfaceId,
33
        CancellationToken cancellationToken = default)
34
    {
35
        var request = _doEventsOkPool.Get();
×
36

37
        try
38
        {
39
            request.Reset(renderingSurfaceId, cancellationToken);
×
40

41
            await _channelWriter.WriteAsync(
×
42
                request,
×
43
                cancellationToken);
×
44

45
            return await request.Invoked;
×
46
        }
47
        finally
48
        {
49
            _doEventsOkPool.Return(request);
×
50
        }
51
    }
×
52

53
    private void Dispose(bool disposing)
54
    {
55
        if (!_disposedValue)
×
56
        {
57
            if (disposing)
×
58
            {
59
                _channelWriter.Complete();
×
60
            }
61

62
            _disposedValue = true;
×
63
        }
64
    }
×
65

66
    public void Dispose()
67
    {
68
        // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
69
        Dispose(disposing: true);
×
70
        GC.SuppressFinalize(this);
×
71
    }
×
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc