예제 #1
0
파일: Lock.Read.cs 프로젝트: perryiv/cadkit
 /// <summary>
 /// Constructor
 /// </summary>
 public ReadLock(System.Threading.ReaderWriterLock lk, System.TimeSpan timeout)
 {
     _lock = lk;
     if (null == _lock)
     {
         throw new System.ArgumentNullException("Error 2719124605: Null lock given");
     }
     try
     {
         // If this thread already holds a write-lock then it is not possible
         // for other threads to hold read- or write-locks, so do nothing.
         // Note: this design assumes the scope of the write-lock held is bigger
         // than this instance.
         if (false == _lock.IsWriterLockHeld)
         {
             _lock.AcquireReaderLock(timeout);
             this._incrementCount();
             //this._printCount();
         }
     }
     catch (System.ApplicationException e)
     {
         System.Console.WriteLine("Error 3866214997: Failed to obtain lock for reading. {0}", e.Message);
         this._printCount();
         throw;
     }
 }
예제 #2
0
 private void initRefreshData()
 {
     // Create properties first.
     this.m_dataLock     = new System.Threading.ReaderWriterLock();
     this.m_dataModified = DateTime.Now;
     LoadAppSettings();
 }
예제 #3
0
 public void Dispose()
 {
     if (this.rwlock != null)
     {
         this.rwlock.DowngradeFromWriterLock(ref this.cookie);
         this.rwlock = null;
     }
 }
예제 #4
0
 public Lock(System.Threading.ReaderWriterLock rwl, LockType lt)
 {
     rwlock = rwl;
     if (type == LockType.ForReading)
         rwl.AcquireReaderLock(-1);
     else if (type == LockType.ForWriting)
         rwl.AcquireWriterLock(-1);
 }
예제 #5
0
 public void Dispose()
 {
     if (this.rwlock != null)
     {
         this.rwlock.ReleaseWriterLock();
         this.rwlock = null;
     }
 }
예제 #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>
        /// <para>
        /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
        /// </para>
        /// </remarks>
        public ReaderWriterLock()
        {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
            m_lock = new System.Threading.ReaderWriterLockSlim();
#else
            m_lock = new System.Threading.ReaderWriterLock();
#endif
#endif
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>
        /// <para>
        /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
        /// </para>
        /// </remarks>
        public ReaderWriterLock()
        {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
            m_lock = new System.Threading.ReaderWriterLockSlim(System.Threading.LockRecursionPolicy.SupportsRecursion);
#else
            m_lock = new System.Threading.ReaderWriterLock();
#endif
#endif
        }
예제 #8
0
        public Lock(System.Threading.ReaderWriterLock rwl, LockType lt)
        {
            rwlock = rwl;
            if (type == LockType.ForReading)
                rwl.AcquireReaderLock(-1);
            else if (type == LockType.ForWriting)
                rwl.AcquireWriterLock(-1);

            #if DEBUG
            callingfunction = new System.Diagnostics.StackTrace();
            #endif
        }
예제 #9
0
 public Lock(System.Threading.ReaderWriterLock rwl, LockType lt)
 {
     rwlock = rwl;
     if (type == LockType.ForReading)
     {
         rwl.AcquireReaderLock(-1);
     }
     else if (type == LockType.ForWriting)
     {
         rwl.AcquireWriterLock(-1);
     }
 }
예제 #10
0
        /// <summary>
        /// <see cref="MMFrame.Windows.WindowMessaging.WindowMessageReceiver"/> オブジェクトを生成します。
        /// </summary>
        public WindowMessageReceiver()
        {
            this.IsDisposed             = false;
            this.Lock                   = new System.Threading.ReaderWriterLock();
            this.CatchMessages          = new System.Collections.Generic.HashSet <int>();
            this.Events                 = new System.Collections.Generic.HashSet <System.Action <System.Windows.Forms.Message> >();
            this.SynchronizationContext = System.ComponentModel.AsyncOperationManager.SynchronizationContext;

            System.Windows.Forms.CreateParams cp = new System.Windows.Forms.CreateParams();
            cp.Caption = GetType().FullName;
            base.CreateHandle(cp);
        }
예제 #11
0
 /// <summary>
 /// Creates a new vertex that can be added to a certain graph, but does not yet add it to the graph
 /// </summary>
 /// <param name="graph">The graph to which this vertex can be added</param>
 /// <param name="cls">The classification id of this vertex</param>
 public Vertex(Network graph, string label)
 {
     ID                    = Guid.NewGuid();
     Network               = graph;
     _predecessors         = new Dictionary <Guid, Vertex>();
     _successors           = new Dictionary <Guid, Vertex>();
     _incomingEdges        = new Dictionary <Guid, Edge>();
     _outgoingEdges        = new Dictionary <Guid, Edge>();
     _undirectedEdges      = new Dictionary <Guid, Edge>();
     _successorToEdgeMap   = new Dictionary <Guid, Edge>();
     _predecessorToEdgeMap = new Dictionary <Guid, Edge>();
     _rwl                  = new System.Threading.ReaderWriterLock();
     Label                 = label;
 }
예제 #12
0
 /// <summary>
 /// Creates a new vertex that can be added to a certain graph, but does not yet add it to the graph
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="id"></param>
 public Vertex(Network graph, Guid id)
 {
     ID                    = id;
     Network               = graph;
     _predecessors         = new Dictionary <Guid, Vertex>();
     _successors           = new Dictionary <Guid, Vertex>();
     _incomingEdges        = new Dictionary <Guid, Edge>();
     _outgoingEdges        = new Dictionary <Guid, Edge>();
     _undirectedEdges      = new Dictionary <Guid, Edge>();
     _successorToEdgeMap   = new Dictionary <Guid, Edge>();
     _predecessorToEdgeMap = new Dictionary <Guid, Edge>();
     _rwl                  = new System.Threading.ReaderWriterLock();
     Label                 = ID.ToString();
 }
예제 #13
0
        public Lock(System.Threading.ReaderWriterLock rwl, LockType lt)
        {
            rwlock = rwl;
            if (type == LockType.ForReading)
            {
                rwl.AcquireReaderLock(-1);
            }
            else if (type == LockType.ForWriting)
            {
                rwl.AcquireWriterLock(-1);
            }

#if DEBUG
            callingfunction = new System.Diagnostics.StackTrace();
#endif
        }
예제 #14
0
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        private ClassFactory()
        {
            var name     = new System.Reflection.AssemblyName("DynamicClasses");
            var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(name, System.Reflection.Emit.AssemblyBuilderAccess.Run);

                        #if ENABLE_LINQ_PARTIAL_TRUST
            new ReflectionPermission(PermissionState.Unrestricted).Assert();
#endif
            try
            {
                module = assembly.DefineDynamicModule("Module");
            }
            finally
            {
                                #if ENABLE_LINQ_PARTIAL_TRUST
                PermissionSet.RevertAssert();
#endif
            }
            classes = new Dictionary <Signature, Type>();
            rwLock  = new System.Threading.ReaderWriterLock();
        }
예제 #15
0
        // Group: Functions
        // __________________________________________________________________________


        /* Constructor: Locale
         */
        static Locale()
        {
            localeCode = System.Globalization.CultureInfo.CurrentCulture.Name;
            if (String.IsNullOrEmpty(localeCode))              // Will be empty for the invariant culture
            {
                localeCode = "default";
            }
            else
            {
                localeCode = localeCode.ToLower();
            }

            translationFolders = new List <Path>(1);
            translationFolders.Add(
                Path.FromAssembly(System.Reflection.Assembly.GetExecutingAssembly()).ParentFolder + "/Translations"
                );

            translations = new StringTable <StringToStringTable>(KeySettingsForLocaleNames);
            accessLock   = new System.Threading.ReaderWriterLock();

            pluralFormatterRegex = new Engine.Regex.Locale.PluralFormatter();
        }
예제 #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 public WriteLock(System.Threading.ReaderWriterLock lk, System.TimeSpan timeout)
 {
     _lock = lk;
     if (null == _lock)
     {
         throw new System.ArgumentNullException("Error 2719124605: Null lock given");
     }
     try
     {
         // If this thread holds a read-lock then it has to release it before
         // getting the write-lock. Otherwise, the attempt to acquire the
         // write-lock below will block.
         if (true == _lock.IsReaderLockHeld)
         {
             throw new System.Exception("Error 3637580726: Reader-lock is already held");
         }
         _lock.AcquireWriterLock(timeout);
     }
     catch (System.ApplicationException e)
     {
         System.Console.WriteLine("Error 3725156970: Failed to obtain lock for writing. {0}", e.Message);
         throw;
     }
 }
예제 #17
0
			void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender)
			{
				rwLock = new System.Threading.ReaderWriterLock();
			}
예제 #18
0
 /// <summary>
 /// 默认改造函数
 /// </summary>
 public ObjectContainer_WuQi(ICacheStorage_WuQi <K, T> ics, ICacheDependency_WuQi <K, T> icd)
 {
     this.obj_dependency = icd;
     this.obj_containers = ics;
     this.obj_rwl        = new System.Threading.ReaderWriterLock();
 }
예제 #19
0
 internal SyncStatementPhoneNumberCollection(StatementPhoneNumberCollection list) : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #20
0
			internal SyncLocalNamespaceList(LocalNamespaceListBase list) : base(Tag.Default)
			{
				rwLock = new System.Threading.ReaderWriterLock();
				collection = list;
			}
예제 #21
0
 internal SyncDoubleCollection(DoubleCollection list) : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #22
0
 public WriterLock(System.Threading.ReaderWriterLock rwlock)
     : this(rwlock, System.Threading.Timeout.Infinite)
 {
 }
예제 #23
0
 internal SyncPreviousPaymentCollection(PreviousPaymentCollection list) : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #24
0
 internal WriterLockUpgraded(System.Threading.ReaderWriterLock rwlock)
     : this(rwlock, System.Threading.Timeout.Infinite)
 {
 }
 internal SyncServiceCategoryCollection(ServiceCategoryCollection list) : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
 /// <summary>
 /// Constructs a new DOLEventHandler collection
 /// </summary>
 public RoadEventHandlerCollection()
 {
     m_lock = new System.Threading.ReaderWriterLock();
     m_events = new HybridDictionary();
 }
예제 #27
0
 internal SyncMailAddressList(MailAddressList list) : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
 internal SyncMarketLogVector( MarketLogVector list )
     : base(Tag.Default)
 {
     rwLock = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #29
0
 /// <summary>
 /// Constructs a new DOLEventHandler collection
 /// </summary>
 public RoadEventHandlerCollection()
 {
     m_lock   = new System.Threading.ReaderWriterLock();
     m_events = new HybridDictionary();
 }
예제 #30
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <remarks>
        /// <para>
        /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
        /// </para>
        /// </remarks>
        public ReaderWriterLock()
        {
#if HAS_READERWRITERLOCK
            m_lock = new System.Threading.ReaderWriterLock();
#endif
        }
예제 #31
0
 internal SyncMarketLogVector(MarketLogVector list)
     : base(Tag.Default)
 {
     rwLock     = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #32
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <remarks>
		/// <para>
		/// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
		/// </para>
		/// </remarks>
		public ReaderWriterLock()
		{
#if HAS_READERWRITERLOCK
			m_lock = new System.Threading.ReaderWriterLock();
#endif
		}
예제 #33
0
 internal SyncQuestionCollection(QuestionCollection list)
     : base(Tag.Default)
 {
     rwLock = new System.Threading.ReaderWriterLock();
     collection = list;
 }
예제 #34
0
 public ReaderLock(System.Threading.ReaderWriterLock rwlock, int milliSeconds)
 {
     this.rwlock = rwlock;
     this.rwlock.AcquireReaderLock(milliSeconds);
 }
예제 #35
0
 internal SyncPropertyCollection(PropertyCollection list)
     : base(Tag.Default)
 {
     _rwLock     = new System.Threading.ReaderWriterLock();
     _collection = list;
 }
예제 #36
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <remarks>
 /// <para>
 /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
 /// </para>
 /// </remarks>
 public ReaderWriterLock()
 {
     m_lock = new System.Threading.ReaderWriterLock();
 }
예제 #37
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <remarks>
 /// <para>
 /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
 /// </para>
 /// </remarks>
 public ReaderWriterLock()
 {
     m_lock = new System.Threading.ReaderWriterLock();
 }
예제 #38
0
 void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender)
 {
     rwLock = new System.Threading.ReaderWriterLock();
 }
예제 #39
0
 internal WriterLockUpgraded(System.Threading.ReaderWriterLock rwlock, int milliSeconds)
 {
     this.cookie = rwlock.UpgradeToWriterLock(milliSeconds);
     this.rwlock = rwlock;
 }