Skip to content

Commit

Permalink
Merge pull request microsoft#851 from sharwell/memory-mapped-streams
Browse files Browse the repository at this point in the history
Memory mapped streams
  • Loading branch information
vancem authored Jan 23, 2019
2 parents 5f1367c + 1b8ed5d commit d3ba24f
Show file tree
Hide file tree
Showing 9 changed files with 861 additions and 181 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>7</LangVersion>
<LangVersion>7.3</LangVersion>
<Features>strict</Features>
</PropertyGroup>

Expand Down
15 changes: 15 additions & 0 deletions src/FastSerialization/FastSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ interface IStreamReader : IDisposable
/// </summary>
string ReadString();
/// <summary>
/// Read a span of bytes from the stream.
/// </summary>
void Read(Span<byte> span);
/// <summary>
/// Read a StreamLabel (pointer to some other part of the stream) from the stream
/// </summary>
StreamLabel ReadLabel();
Expand Down Expand Up @@ -1126,6 +1130,17 @@ public IFastSerializable GetEntryObject()
}

// For FromStream method bodies.
public void Read(Span<byte> span)
{
#if DEBUG
StreamLabel label = reader.Current;
#endif
reader.Read(span);
#if DEBUG
Log("<Read Value=\"" + "[...]" + "\" StreamLabel=\"0x" + label.ToString("x") + "\"/>");
#endif
}

/// <summary>
/// Read a bool from the stream
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/FastSerialization/FastSerialization.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
<Copyright>Copyright © Microsoft 2010</Copyright>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard1.3'">
<ItemGroup>
<PackageReference Include="System.IO.MemoryMappedFiles" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
</ItemGroup>
</When>
</Choose>

<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.0" />
</ItemGroup>

<PropertyGroup>
<DefineConstants>$(DefineConstants);GROWABLEARRAY_PUBLIC;STREAMREADER_PUBLIC;FASTSERIALIZATION_PUBLIC</DefineConstants>
</PropertyGroup>
Expand Down
Loading

0 comments on commit d3ba24f

Please sign in to comment.