RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Multiple Processor test logic in Main()

Ohms_Law

Wanderer
Multiple Processor test logic in Main()

In the Main method (svn 187), there's some logic to test for multiple processors. The original code is all at the (relative) beginning of the main method (starts at ~ line 410):

Code:
			int processorCount = Environment.ProcessorCount;

			if( processorCount > 1 )
				m_MultiProcessor = true;

			if( m_MultiProcessor || Is64Bit )
				Console.WriteLine( "Core: Optimizing for {0} {2}processor{1}", processorCount, processorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "" );

			m_ProcessorCount = processorCount;

For the field definitions, the original is:
Code:
		private static bool m_MultiProcessor;
		private static int m_ProcessorCount;
it's probably better to do:
Code:
        private static bool m_MultiProcessor;

        public static bool MultiProcessor
        {
            get
            {
                if(Environment.ProcessorCount > 1)
                    m_MultiProcessor = true;
                else
                    m_MultiProcessor = false;
                return m_MultiProcessor;
            }
            set
            {
                m_MultiProcessor = value;
            }
        }
(hungarian notation... *puke*)

and then all that's needed in the main method is:
Code:
            if(MultiProcessor || Is64Bit)
                Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", processorCount, processorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "");
 

Jeff

Lord
Its all relative, but if your trying to point out these semi-useless quirks(which is all just coding preference tbh) why didnt you go into 100% constructive detail and just do

Code:
        public static bool MultiProcessor
        {
           get
            {
                return (Environment.ProcessorCount > 1);
            }
        }

remove the set, since you cant set your processor count in the fucking 1st place, remove m_MultiProcessor and m_ProcessorCount.... your picky...
 
Top