22using System . IO ;
33using System . Threading ;
44using JetBrains . Annotations ;
5+ using PatchKit . Unity . Patcher . Debug ;
56
67namespace PatchKit . Unity . Patcher . AppData . Local
78{
89 public class ThreadBufferedStream : Stream
910 {
11+ private static readonly DebugLogger DebugLogger = new DebugLogger ( typeof ( ThreadBufferedStream ) ) ;
12+
1013 private readonly Stream _innerStream ;
1114 private readonly byte [ ] _buffer ;
1215
@@ -68,12 +71,12 @@ private void SpawnReaderThread()
6871 {
6972 try
7073 {
71- //UnityEngine.Debug .Log("Entering semaphore from thread...");
74+ //DebugLogger .Log("Entering semaphore from thread...");
7275 _semaphore . WaitOne ( ) ;
7376 {
7477 if ( _eof )
7578 {
76- //UnityEngine.Debug .Log("BREAKING semaphore from thread...");
79+ //DebugLogger .Log("BREAKING semaphore from thread...");
7780 break ;
7881 }
7982
@@ -85,7 +88,7 @@ private void SpawnReaderThread()
8588 }
8689 finally
8790 {
88- //UnityEngine.Debug .Log("Leaving semaphore from thread.");
91+ //DebugLogger .Log("Leaving semaphore from thread.");
8992 _semaphore . Release ( ) ;
9093 }
9194
@@ -100,7 +103,7 @@ public override int Read(byte[] buffer, int offset, int count)
100103
101104 try
102105 {
103- //UnityEngine.Debug .Log("Entering semaphore from Read..." + count);
106+ //DebugLogger .Log("Entering semaphore from Read..." + count);
104107 _semaphore . WaitOne ( ) ;
105108 {
106109 // repeat while there's something to read
@@ -131,36 +134,36 @@ public override int Read(byte[] buffer, int offset, int count)
131134 if ( copied == count )
132135 {
133136 // all bytes has been copied
134- //UnityEngine.Debug .Log("BREAK semaphore from Read.");
137+ //DebugLogger .Log("BREAK semaphore from Read.");
135138 break ;
136139 }
137140 }
138141 }
139142 }
140143 finally
141144 {
142- //UnityEngine.Debug .Log("Leaving semaphore from Read.");
145+ //DebugLogger .Log("Leaving semaphore from Read.");
143146 _semaphore . Release ( ) ;
144147 }
145148
146149 _position += copied ;
147150
148- //UnityEngine.Debug .Log("Returning " + copied);
151+ //DebugLogger .Log("Returning " + copied);
149152
150153 return copied ;
151154 }
152155
153156 private void ReadToBuffer ( )
154157 {
155158 int size = _buffer . Length - _bufferedBytes ;
156- //UnityEngine.Debug .Log("Reading into buffer " + size);
159+ //DebugLogger .Log("Reading into buffer " + size);
157160
158161 int read = _innerStream . Read ( _buffer , _bufferedBytes , size ) ;
159162 _bufferedBytes += read ;
160163
161164 if ( read == 0 )
162165 {
163- //UnityEngine .Debug.Log("End of file");
166+ //DebugLogger .Debug.Log("End of file");
164167 _eof = true ;
165168 }
166169 }
0 commit comments