コード例 #1
0
        /// <summary>
        ///     Lock read @lock.
        /// </summary>
        public void AcquireReadLock()
        {
            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRE_TEXT + " read ", _lock);
            }

            _readLock = _lock.ReadLock.Acquire();

            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRED_TEXT + " read ", _lock);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Lock write @lock.
        /// </summary>
        public void AcquireWriteLock()
        {
            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRE_TEXT + " write ", _lock);
            }

            _writeLock = _lock.WriteLock.Acquire();

            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRED_TEXT + " write ", _lock);
            }
        }
コード例 #3
0
        public bool AcquireWriteLock(long msecTimeout)
        {
            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRE_TEXT + " write ", _lock);
            }

            _writeLock = _lock.WriteLock.Acquire(msecTimeout);

            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(ACQUIRED_TEXT + " write ", _lock);
            }

            return true;
        }
コード例 #4
0
        /// <summary>
        ///     Unlock write @lock.
        /// </summary>
        public void ReleaseWriteLock()
        {
            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(RELEASE_TEXT + " write ", _lock);
            }

            if (_writeLock == null) {
                throw new EPLockException("writeLock was not acquired");
            }

            _writeLock.Dispose();
            _writeLock = null;

            if (ThreadLogUtil.ENABLED_TRACE) {
                ThreadLogUtil.TraceLock(RELEASED_TEXT + " write ", _lock);
            }
        }