コード例 #1
0
        public void Add(string key, TMemberType member)
        {
            _readWriteLock.EnterWriteLock();
            try
            {
                KeyToMemberAndItsHashFunction[key] = new MemberAndItsHashFunction
                {
                    Member       = member,
                    HashFunction = new UniversalHashFunction(_masterKey + ":" + key, 16)
                };

                MembersAndTheirHashFunctionsAsArray = null;
            }
            finally
            {
                _readWriteLock.ExitWriteLock();
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a new member to the ring.
        /// </summary>
        /// <param name="key">The key of the member to add to the ring.</param>
        /// <param name="member">The member to add to the ring</param>
        public void Add(string key, TMemberType member)
        {
            // Lock to ensure thread safety
            _readWriteLock.EnterWriteLock();
            try
            {
                KeyToMemberAndItsHashFunction[key] = new MemberAndItsHashFunction
                {
                    Member       = member,
                    HashFunction = new UniversalHashFunction(_masterKey + ":" + key, 16)
                };

                // Reset the fast-access array of the members and their hash functions
                MembersAndTheirHashFunctionsAsArray = null;
            }
            finally
            {
                _readWriteLock.ExitWriteLock();
            }
        }