コード例 #1
0
        /// <summary>
        /// Reserve an object, returning true when successfully reserved or false when the
        /// object is already reserved.
        /// </summary>
        /// <param name="object">object to reserve</param>
        /// <returns>
        /// true if reserved, false to indicate already reserved
        /// </returns>
        public bool Reserve(Object @object)
        {
            bool rvalue = false;

            reservedIdsLock.Call(() => rvalue = !reservedObjects.Add(@object));
            return(rvalue);
        }
コード例 #2
0
        /// <summary>
        /// Reserve an object, returning true when successfully reserved or false when the
        /// object is already reserved.
        /// </summary>
        /// <param name="object">object to reserve</param>
        /// <returns>
        /// true if reserved, false to indicate already reserved
        /// </returns>
        public bool Reserve(object @object)
        {
            var rvalue = _reservedIdsLock.Call(() => {
#if DEBUG && DIAGNOSTIC
                Log.Info("Reserved / Value = {0} / {1}", @object, _reservedObjects.Count);
#endif
                return(_reservedObjects.Add(@object));
            });

#if DEBUG && DIAGNOSTIC
            Log.Info("Reserved / Result = {0} / {1}", @object, rvalue);
#endif
            return(rvalue);
        }