SafeBufferMemoryManager

Đang mở
#1,197 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các API SafeBufferMemoryManager và MemoryMappedFileExtensions được đề xuất, cùng với hành vi của .NET MemoryManager, SafeBuffer và MemoryMappedFile mà chúng bọc lại. Công việc được xem là hoàn tất khi các constructor được liệt kê, việc truy cập span, pinning, giải phóng và các overload của file hoạt động với ví dụ sử dụng, kèm theo các test bao phủ các tham số offset, size và access được hỗ trợ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

feature request :mailbox_with_mail:
Overview

Exposing a MemoryManager that would make access to memory mapped files easier would help projects interacting with them.

API breakdown
public sealed class SafeBufferMemoryManager : MemoryManager<byte>
{
    public SafeBufferMemoryManager(SafeBuffer buffer);
    public override Span<byte> GetSpan();
    public override MemoryHandle Pin(int elementIndex = 0);
    public override void Unpin();
    protected override void Dispose(bool disposing);
}

public static class MemoryMappedFileExtensions
{
    public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file);
    public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file, long offset, int size);
    public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file, long offset, int size, MemoryMappedFileAccess access);
}
Usage example
using MemoryMappedFile file = ...;
using SafeBufferMemoryManager memoryManager = file.CreateMemoryManager();
SomeApi(memoryManager.Memory.Span);
Breaking change?

No

Alternatives

https://github.com/dotnet/runtime/issues/37227

Additional context

No response

Help us help you

No, just wanted to propose this

Ngôn ngữ chính
C#
Star
3.8k
Fork
402
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CommunityToolkit/dotnet

Tất cả issue của CommunityToolkit/dotnet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.