Decision trie data structure provider.
Наследование: IDisposable
Пример #1
0
 public void CleanUp()
 {
     _provider.Dispose();
     _provider = null;
     GC.Collect(int.MaxValue, GCCollectionMode.Forced, true);
     GC.WaitForPendingFinalizers();
 }
Пример #2
0
 /// <summary>
 /// In a single thread loops through the useragents in the file
 /// provided perform a match with the data set provided passing
 /// control back to the method provided for further processing.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userAgents"></param>
 /// <param name="method"></param>
 /// <returns>Counts for each of the methods used</returns>
 internal static Results DetectLoopSingleThreaded(TrieProvider provider, IEnumerable<string> userAgents, ProcessTrie method, object state)
 {
     var results = new Results();
     foreach (var line in userAgents)
     {
         method(results, provider.GetDeviceIndex(line.Trim()), state);
         results.Count++;
     }
     ReportMethods(results.Methods);
     ReportTime(results);
     return results;
 }
Пример #3
0
 /// <summary>
 /// Using multiple threads loops through the useragents in the file
 /// provided perform a match with the data set provided passing
 /// control back to the method provided for further processing.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userAgents"></param>
 /// <param name="method"></param>
 /// <returns>Counts for each of the methods used</returns>
 internal static Results DetectLoopMultiThreaded(TrieProvider provider, IEnumerable<string> userAgents, ProcessTrie method, object state)
 {
     var results = new Results();
     Parallel.ForEach(userAgents, line =>
     {
         method(results, provider.GetDeviceIndex(line.Trim()), state);
         Interlocked.Increment(ref results.Count);
     });
     ReportMethods(results.Methods);
     ReportTime(results);
     return results;
 }
Пример #4
0
 public void CreateDataSet()
 {
     Utils.CheckFileExists(DataFile);
     _provider = TrieFactory.Create(DataFile, false);
 }
Пример #5
0
 /// <summary>
 /// Create the two providers for managed and unmanaged code.
 /// </summary>
 public virtual void Initialise()
 {
     _unmanagedProvider = new TrieWrapper(DataFile);
     _managedProvider = TrieFactory.Create(DataFile);
 }
Пример #6
0
 /// <summary>
 /// Disposes of the providers if not already done so.
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Disposing(bool disposing) 
 {
     if (_managedProvider != null)
     {
         _managedProvider.Dispose();
         _managedProvider = null;
     }
     if (_unmanagedProvider != null)
     {
         _unmanagedProvider.Dispose();
         _unmanagedProvider = null;
     }
 }