< Summary

Information
Class: MyNet.Collections.ImmediateCollectionSynchronizer
Assembly: MyNet.Collections
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Collections/ImmediateCollectionSynchronizer.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 54
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
Write(...)100%11100%
Write(...)100%11100%
Read(...)100%11100%
Read(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Collections/ImmediateCollectionSynchronizer.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ImmediateCollectionSynchronizer.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8
 9namespace MyNet.Collections;
 10
 11/// <summary>
 12/// Current collection synchronizer that performs no synchronization, for use when thread safety is not required.
 13/// </summary>
 14public sealed class ImmediateCollectionSynchronizer : ICollectionSynchronizer
 15{
 16    /// <summary>
 17    /// Gets the default instance of the collection synchronizer that performs no synchronization.
 18    /// </summary>
 319    public static ImmediateCollectionSynchronizer Default { get; } = new();
 20
 21    /// <summary>
 22    /// Initializes a new instance of the <see cref="ImmediateCollectionSynchronizer"/> class.
 23    /// </summary>
 324    private ImmediateCollectionSynchronizer() { }
 25
 26    /// <summary>
 27    /// Executes the specified action without any synchronization, as this implementation does not provide thread safety
 28    /// </summary>
 29    /// <param name="action">The action to execute.</param>
 2130    public void Write(Action action) => action();
 31
 32    /// <summary>
 33    /// Executes the specified function without any synchronization, as this implementation does not provide thread safe
 34    /// </summary>
 35    /// <typeparam name="TResult">The type of the result.</typeparam>
 36    /// <param name="func">The function to execute.</param>
 37    /// <returns>The result of the function.</returns>
 938    public TResult Write<TResult>(Func<TResult> func) => func();
 39
 40    /// <summary>
 41    /// Executes the specified action without any synchronization, as this implementation does not provide thread safety
 42    /// </summary>
 43    /// <param name="action">The action to execute.</param>
 944    public void Read(Action action) => action();
 45
 46    /// <summary>
 47    /// Executes the specified function without any synchronization, as this implementation does not provide thread safe
 48    /// </summary>
 49    /// <typeparam name="TResult">The type of the result.</typeparam>
 50    /// <param name="func">The function to execute.</param>
 51    /// <returns>The result of the function.</returns>
 2152    public TResult Read<TResult>(Func<TResult> func) => func();
 53}
 54