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

DemoBytom / DemoEngine / 24861970515

23 Apr 2026 10:23PM UTC coverage: 30.3% (-0.09%) from 30.388%
24861970515

push

coveralls.net

DemoBytom
Abstracting the `StaThreadReader`

The functionality of reading from the `StaThreadRequest` channel has been abstracted, so that now the consumer can now provide a lambda used for invocation purposes of each request. This means the `StaThreadRequests` can go back to being internal implementation detail of the channel.
Also refactored `WindowsMessagePump` to now be asynchronously disposed. The `MarshallingControl` is now disposed after the `StaThreadRequest` channel stops being served.
Removed `InvokeAsync` and `CreateSurface` from the `IRenderingControl` interface.

1282 of 4231 relevant lines covered (30.3%)

0.37 hits per line

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

0.0
/src/Demo.Engine.Core/Features/StaThread/StaThreadRegistrationExtensions.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 Microsoft.Extensions.DependencyInjection;
6
using Microsoft.Extensions.DependencyInjection.Extensions;
7
using Microsoft.Extensions.ObjectPool;
8
using WorkItem = Demo.Engine.Core.Features.StaThread.StaThreadService.StaSingleThreadedSynchronizationContext.WorkItem;
9

10
namespace Demo.Engine.Core.Features.StaThread;
11

12
internal static class StaThreadRegistrationExtensions
13
{
14
    public static IServiceCollection AddStaThreadFeature(
15
        this IServiceCollection services)
16
    {
17
        _ = services
×
18
            .AddScoped<IStaThreadService, StaThreadService>()
×
19
            .AddSingletonBoundedChannel<StaThreadRequests>(
×
20
                new BoundedChannelOptions(10)
×
21
                {
×
22
                    AllowSynchronousContinuations = false,
×
23
                    FullMode = BoundedChannelFullMode.Wait,
×
24
                    SingleReader = true,
×
25
                    SingleWriter = false,
×
26
                })
×
27
            .AddSingleton<IStaThreadWriter, StaThreadWriter>()
×
28
            .AddSingleton<IStaThreadReader, StaThreadReader>()
×
29
            .AddStaWorkItemObjectPool()
×
30
            ;
×
31

32
        services
×
33
            .TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
×
34
        services
×
35
            .TryAddSingleton(sp
×
36
                =>
×
37
            {
×
38
                var provider = sp.GetRequiredService<ObjectPoolProvider>();
×
39
                var policy = new DefaultPooledObjectPolicy<StaThreadRequests.DoEventsOkRequest>();
×
40

×
41
                var created = provider.Create(policy);
×
42

×
43
                return created;
×
44
            });
×
45

46
        return services;
×
47
    }
48

49
    internal static IServiceCollection AddStaWorkItemObjectPool(
50
        this IServiceCollection services)
51
    {
52
        services
×
53
            .TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
×
54

55
        services
×
56
            .TryAddSingleton(sp
×
57
                =>
×
58
            {
×
59
                var provider = sp.GetRequiredService<ObjectPoolProvider>();
×
60
                var policy = new DefaultPooledObjectPolicy<WorkItem>();
×
61
                var created = provider.Create(policy);
×
62
                return created;
×
63
            });
×
64

65
        return services;
×
66
    }
67
}
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