@@ -24,7 +24,11 @@ public sealed class Program
24
24
"Date:DDD, dd mmm yyyy hh:mm:ss GMT" +
25
25
"\r \n \r \n " ;
26
26
27
- private static byte [ ] _headersBytes = Encoding . ASCII . GetBytes ( headersKeepAliveStr ) ;
27
+ private static byte [ ] [ ] _headersBytesBuffers = new byte [ ] [ ] {
28
+ Encoding . ASCII . GetBytes ( headersKeepAliveStr ) ,
29
+ Encoding . ASCII . GetBytes ( headersKeepAliveStr )
30
+ } ;
31
+ private static byte [ ] _headersBytes ;
28
32
29
33
private static readonly string bodyStr = "Hello, World!" ;
30
34
@@ -33,11 +37,14 @@ public sealed class Program
33
37
34
38
static Program ( )
35
39
{
36
- var start = _headersBytes . Length - 33 ;
40
+ var start = _headersBytesBuffers [ 0 ] . Length - 33 ;
41
+ var loop = 0u ;
37
42
UpdateDateTimer = new Timer ( ( obj ) =>
38
43
{
39
- var date = DateTime . UtcNow . ToString ( "r" ) ;
40
- Encoding . ASCII . GetBytes ( date , 0 , date . Length , _headersBytes , start ) ;
44
+ var date = DateTime . UtcNow . ToString ( "r" ) ;
45
+ var index = ( ++ loop ) & 1 ;
46
+ Encoding . ASCII . GetBytes ( date , 0 , date . Length , _headersBytesBuffers [ index ] , start ) ;
47
+ _headersBytes = _headersBytesBuffers [ index ] ;
41
48
} , null , 0 , 1000 ) ;
42
49
}
43
50
@@ -46,7 +53,7 @@ static void Main(string[] args)
46
53
Console . WriteLine ( "Starting Managed Registered IO Server" ) ;
47
54
Console . WriteLine ( "* Hardware Accelerated SIMD: {0}" , Vector . IsHardwareAccelerated ) ;
48
55
Console . WriteLine ( "* Vector<byte>.Count: {0}" , Vector < byte > . Count ) ;
49
-
56
+
50
57
if ( IntPtr . Size != 8 )
51
58
{
52
59
Console . WriteLine ( "ManagedRIOHttpServer needs to be run in x64 mode" ) ;
@@ -186,7 +193,7 @@ static async Task ServeSocket(RIOTcpConnection socket)
186
193
187
194
var ul = r - 3 ;
188
195
var hasStart = false ;
189
-
196
+
190
197
191
198
for ( var i = start ; i < buffer . Length - Vector < byte > . Count ; i += Vector < byte > . Count )
192
199
{
@@ -284,8 +291,8 @@ static async Task ServeSocket(RIOTcpConnection socket)
284
291
socket . SendCachedBad ( ) ;
285
292
break ;
286
293
}
287
-
288
-
294
+
295
+
289
296
for ( var i = 1 ; i < count ; i ++ )
290
297
{
291
298
socket . QueueSend ( headerBuffer , false ) ;
@@ -317,7 +324,7 @@ static async Task ServeSocket(RIOTcpConnection socket)
317
324
// }
318
325
// var A = new Vector<byte>(65); // A
319
326
// var Z = new Vector<byte>(90); // Z
320
-
327
+
321
328
// for (var o = data.Offset; o < data.Count - Vector<byte>.Count; o += Vector<byte>.Count)
322
329
// {
323
330
// var v = new Vector<byte>(data.Array, o);
0 commit comments