예제 #1
0
 static void MultiThreadTest()
 {
     log = FileLog.Create("multi.db", false).Result;
     var clock = new Stopwatch();
     try
     {
         tmpbuf = Encoding.ASCII.GetBytes(TXT);
         clock.Start();
         var t0 = Task.Run(new Action(Run));
         var t1 = Task.Run(new Action(Run));
         Run();
         t0.Wait();
         t1.Wait();
         clock.Stop();
         //log.Stats();
         var count = 0;
         using (var ie = log.Replay(log.First))
         {
             while (ie.MoveNext().Result)
             {
                 using (var tr = new StreamReader(ie.Stream))
                 {
                     Debug.Assert(tr.ReadToEnd() == TXT);
                     ++count;
                 }
             }
         }
         PrintStats("FileLog", clock.ElapsedMilliseconds);
         Debug.Assert(count == 3 * ITER);
     }
     finally
     {
         log.Dispose();
         File.Delete(Path.GetFullPath("multi.db"));
     }
 }
예제 #2
0
 public EventEnumerator(FileLog log, TransactionId last)
 {
     Contract.Requires(log != null);
     this.log = log;
     this.file = new FileStream(log.path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true);
     this.length = last.Id;
     this.Transaction = default(TransactionId);
 }
예제 #3
0
 public Appender(FileLog log, byte[] buf)
 {
     Contract.Requires(log != null);
     Contract.Requires(buf != null);
     Contract.Requires(buf.Length >= sizeof(long));
     this.buf = buf;
     this.log = log;
     this.writer = log.writer;
 }