Exemplo n.º 1
0
        private static Results MatchMultiProcessor(string userAgent, SegmentHandler handler)
        {
            // Provide an object to signal when the request has completed.
            AutoResetEvent waiter = new AutoResetEvent(false);

            // Create the request.
            Request request = new Request(userAgent, handler, waiter);
            if (request.Count > 0)
            {
                // For each thread add this to the queue.
                for (int i = 0; i < Environment.ProcessorCount; i++)
                    ThreadPool.QueueUserWorkItem(ServiceRequest, request);

                // Wait until a signal is received. Keeping coming back to
                // this thread so that a request to close the request
                // can be processed.
                while (waiter.WaitOne(1, false) == false)
                {
                    // Do nothing
                }
                ;
            }
            // Return the results.
            return request.Results;
        }
Exemplo n.º 2
0
 private static Results MatchSingleProcessor(string userAgent, SegmentHandler handler)
 {
     // Create a segment matcher request.
     Request request = new Request(userAgent, handler);
     // Process the request.
     ServiceRequest(request);
     // Return the results.
     return request.Results;
 }
Exemplo n.º 3
0
 internal static Results Match(string userAgent,
     SegmentHandler handler)
 {
     if (handler.UserAgents.Count > 0)
     {
         if (Environment.ProcessorCount > 1 &&
             Detection.Constants.ForceSingleProcessor == false)
         {
             return MatchMultiProcessor(userAgent, handler);
         }
         else
         {
             return MatchSingleProcessor(userAgent, handler);
         }
     }
     return null;
 }
Exemplo n.º 4
0
 internal Request(string userAgent, SegmentHandler handler, AutoResetEvent completeEvent)
     : base(userAgent, handler, completeEvent)
 {
     _target = Handler.CreateSegments(userAgent);
     _results = new Results();
 }
Exemplo n.º 5
0
 internal Request(string userAgent, SegmentHandler handler)
     : base(userAgent, handler)
 {
     _target = Handler.CreateSegments(userAgent);
     _results = new Results();
 }