Beispiel #1
0
        public FastReaderWriterLock()
        {
            var proc = System.Diagnostics.Process.GetCurrentProcess();
            int coreFlag;

            if (Environment.ProcessorCount == 1)
            {
                coreFlag = 0x0001;
            }
            else if (Environment.ProcessorCount == 2)
            {
                coreFlag = 0x0003;
            }
            else if (Environment.ProcessorCount == 3)
            {
                coreFlag = 0x0007;
            }
            else
            {
                coreFlag = 0x000F;  //use only 4 cores.We dont care for pcs with more than 4 cores.
            }
            proc.ProcessorAffinity = new IntPtr(coreFlag);

            if (UseNativeSRWLock)
            {
                NativeMethods.InitializeSRWLock(out this.LockSRW);
            }
            else
            {
                pLock = new FastResourceLock();
            }
        }
Beispiel #2
0
        public FastReaderWriterLock()
        {
            if (UseNativeSRWLock)
            {
                NativeMethods.InitializeSRWLock(out LockSRW);
            }
            else
            {
#if UseFastResourceLock
                pLock = new FastResourceLock();
#endif
            }
        }
        public FastReaderWriterLock()
        {
            if (UseNativeSRWLock)
            {
                NativeMethods.InitializeSRWLock(out this.LockSRW);
            }
            else
            {
#if UseFastResourceLock
                pLock = new FastResourceLock();
#endif
            }
        }