Changeset 4643

Show
Ignore:
Timestamp:
02/19/08 23:02:26 (10 months ago)
Author:
xmlhacker
Message:

changed to using a queue

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/nuxleus/Source/Nuxleus.Web/HttpApplication/Global.cs

    r4641 r4643  
    4949        AmazonSimpleDBClient m_amazonSimpleDBClient; 
    5050        PledgeCount m_pledgeCount; 
     51        Queue<string> m_pledgeQueue; 
    5152        static HashAlgorithm m_hashAlgorithm = HashAlgorithm.MD5; 
    5253 
     
    7576            m_encoding = new UTF8Encoding(); 
    7677            m_pledgeCount = new PledgeCount(0, 0); 
     78            m_pledgeQueue = new Queue<string>(); 
    7779             
    7880            string sdbAccessKey = String.Empty; 
     
    161163            Application["as_simpledbclient"] = m_amazonSimpleDBClient; 
    162164            Application["as_pledgeCount"] = m_pledgeCount; 
     165            Application["as_pledgeQueue"] = m_pledgeQueue; 
    163166        } 
    164167 
     
    177180            Application["simpledbclient"] = Application["as_simpledbclient"]; 
    178181            Application["pledgeCount"] = Application["as_pledgeCount"]; 
     182            Application["pledgeQueue"] = Application["as_pledgeQueue"]; 
    179183        } 
    180184 
  • trunk/nuxleus/Source/Nuxleus.Web/HttpHandler/NuxleusHttpAsyncFormHandler.cs

    r4642 r4643  
    1414using Nuxleus.Agent; 
    1515using Nuxleus.Web.HttpApplication; 
     16using System.Collections.Generic; 
    1617 
    1718namespace Nuxleus.Web.HttpHandler { 
     
    5657            m_pledgeCount = (PledgeCount)context.Application["pledgeCount"]; 
    5758 
     59            Queue<string> pledgeQueue = (Queue<string>)context.Application["pledgeQueue"]; 
     60 
     61 
    5862            m_putAttributes = new PutAttributes(); 
    5963            m_putAttributes.DomainName = "4lessig-dev"; 
     
    6771                ); 
    6872 
    69             if (location == "ca12thdistrict") { 
    70                 lock (m_lock) { 
    71                     m_pledgeCount.PledgeCountDistrict = m_pledgeCount.PledgeCountDistrict + 1; 
    72                     m_pledgeCount.PledgeCountTotal = m_pledgeCount.PledgeCountTotal + 1; 
    73                 } 
    74             } else { 
    75                 lock (m_lock) { 
    76                     m_pledgeCount.PledgeCountTotal = m_pledgeCount.PledgeCountTotal + 1; 
    77                 } 
    78             } 
     73            pledgeQueue.Enqueue(location); 
     74 
     75            //if (location == "ca12thdistrict") { 
     76            //    lock (m_lock) { 
     77            //        m_pledgeCount.PledgeCountDistrict = m_pledgeCount.PledgeCountDistrict + 1; 
     78            //        m_pledgeCount.PledgeCountTotal = m_pledgeCount.PledgeCountTotal + 1; 
     79            //    } 
     80            //} else { 
     81            //    lock (m_lock) { 
     82            //        m_pledgeCount.PledgeCountTotal = m_pledgeCount.PledgeCountTotal + 1; 
     83            //    } 
     84            //} 
    7985 
    8086            Console.WriteLine("District Count: {0}, Total Count: {1}", m_pledgeCount.PledgeCountDistrict, m_pledgeCount.PledgeCountTotal); 
  • trunk/nuxleus/Source/Nuxleus.Web/HttpHandler/NuxleusHttpAsyncRequestValidationHandler.cs

    r4641 r4643  
    3131    { 
    3232        NuxleusAsyncResult m_asyncResult; 
    33         PledgeCount m_pledgeCount; 
     33        int m_pledgeCountDistrict; 
     34        int m_pledgeCountTotal; 
    3435         
    3536        public void ProcessRequest(HttpContext context) 
     
    4950            m_asyncResult = new NuxleusAsyncResult(cb, extraData); 
    5051 
    51             m_pledgeCount = (PledgeCount)context.Application["pledgeCount"]; 
     52            Queue<string> pledgeQueue = (Queue<string>)context.Application["pledgeQueue"]; 
     53 
     54            if (pledgeQueue.Count > 0) { 
     55                while (pledgeQueue.Count != 0) { 
     56                    string location = pledgeQueue.Dequeue(); 
     57                    if (location == "ca12thdistrict") { 
     58                        m_pledgeCountDistrict++; 
     59                        m_pledgeCountTotal++; 
     60                    } else { 
     61                        m_pledgeCountTotal++; 
     62                    } 
     63                } 
     64            } 
    5265 
    5366            using(XmlWriter writer = XmlWriter.Create(context.Response.Output)) 
     
    5972                        writer.WriteStartElement("session"); 
    6073                            writer.WriteStartAttribute("request-total"); 
    61                                 writer.WriteString(m_pledgeCount.PledgeCountTotal.ToString()); 
     74                            writer.WriteString(m_pledgeCountTotal.ToString()); 
    6275                            writer.WriteEndAttribute(); 
    6376                            writer.WriteStartAttribute("request-district"); 
    64                             writer.WriteString(m_pledgeCount.PledgeCountDistrict.ToString()); 
     77                            writer.WriteString(m_pledgeCountDistrict.ToString()); 
    6578                            writer.WriteEndAttribute(); 
    6679                        writer.WriteEndElement();