Exemple #1
0
 /// <summary>
 /// Attempt to lock the specified item and return immediately.
 /// </summary>
 /// <remarks>
 /// This method behaves exactly as if it simply performs the call
 /// <b>Lock(key, 0)</b>.
 /// </remarks>
 /// <param name="key">
 /// Key being locked.
 /// </param>
 /// <returns>
 /// <b>true</b> if the item was successfully locked; <b>false</b>
 /// otherwise.
 /// </returns>
 public virtual bool Lock(object key)
 {
     return(NamedCache.Lock(key));
 }
Exemple #2
0
 /// <summary>
 /// Attempt to lock the specified item within the specified period of
 /// time.
 /// </summary>
 /// <remarks>
 /// <p>
 /// The item doesn't have to exist to be <i>locked</i>. While the
 /// item is locked there is known to be a <i>lock holder</i> which
 /// has an exclusive right to modify (calling put and remove methods)
 /// that item.</p>
 /// <p>
 /// Lock holder is an abstract concept that depends on the
 /// IConcurrentCache implementation. For example, holder could
 /// be a cluster member or a thread (or both).</p>
 /// <p>
 /// Locking strategy may vary for concrete implementations as well.
 /// Lock could have an expiration time (this lock is sometimes called
 /// a "lease") or be held indefinitely (until the lock holder
 /// terminates).</p>
 /// <p>
 /// Some implementations may allow the entire map to be locked. If
 /// the map is locked in such a way, then only a lock holder is
 /// allowed to perform any of the "put" or "remove" operations.</p>
 /// <p>
 /// Passing the special constant
 /// <see cref="LockScope.LOCK_ALL"/> as the <i>key</i>
 /// parameter to indicate the cache lock is not allowed for
 /// WrapperNamedCache and will cause an exception to be thrown.</p>
 /// </remarks>
 /// <param name="key">
 /// Key being locked.
 /// </param>
 /// <param name="waitTimeMillis">
 /// The number of milliseconds to continue trying to obtain a lock;
 /// pass zero to return immediately; pass -1 to block the calling
 /// thread until the lock could be obtained.
 /// </param>
 /// <returns>
 /// <b>true</b> if the item was successfully locked within the
 /// specified time; <b>false</b> otherwise.
 /// </returns>
 public virtual bool Lock(object key, long waitTimeMillis)
 {
     return(NamedCache.Lock(key, waitTimeMillis));
 }