/// <summary> /// join a handle /// </summary> /// <param name="handle"></param> /// <returns></returns> internal void Add(WaitTableHandle handle) { lock (this.lockObject) { this.dictionary.Add(handle.Identity, handle); } }
/// <summary> /// craete a handle /// </summary> /// <param name="handle"></param> /// <returns></returns> internal void Remove(WaitTableHandle handle) { lock (this.lockObject) { this.dictionary.Remove(handle.Identity); } }
/// <summary> /// get all handles /// </summary> /// <returns></returns> public WaitTableHandle[] GetHandles() { WaitTableHandle[] handles = null; lock (this.lockObject) { handles = new WaitTableHandle[this.dictionary.Count]; this.dictionary.Values.CopyTo(handles, 0); } return(handles); }
///// <summary> ///// set a handle ///// </summary> ///// <param name="identity"></param> ///// <returns></returns> //public bool Set(long identity) //{ // var handle = this.GetHandle(identity); // if (handle == null) // return false; // handle.Set(); // return true; //} ///// <summary> ///// set a handle ///// </summary> ///// <param name="identity"></param> ///// <param name="userState"></param> ///// <returns></returns> //public bool Set(long identity, object userState) //{ // var handle = this.GetHandle(identity); // if (handle == null) // return false; // handle.UserState = userState; // handle.Set(); // return true; //} ///// <summary> ///// set a handle ///// </summary> ///// <param name="identity"></param> ///// <param name="userIdentity"></param> ///// <returns></returns> //public bool Set(long identity, int userIdentity) //{ // var handle = this.GetHandle(identity); // if (handle == null) // return false; // handle.UserIdentity = userIdentity; // handle.Set(); // return true; //} ///// <summary> ///// reset a handle ///// </summary> ///// <param name="identity"></param> ///// <returns></returns> //public bool Reset(long identity) //{ // var handle = this.GetHandle(identity); // if (handle == null) // return false; // handle.Reset(); // return true; //} ///// <summary> ///// set a handle user state ///// </summary> ///// <param name="identity"></param> ///// <param name="userState"></param> ///// <returns></returns> //public bool SetUserState(long identity,object userState) //{ // var handle = this.GetHandle(identity); // if (handle == null) // return false; // handle.UserState = userState; // return true; //} /// <summary> /// get handle /// </summary> /// <param name="identity"></param> /// <returns></returns> public WaitTableHandle GetHandle(long identity) { WaitTableHandle handle = null; lock (this.lockObject) { this.dictionary.TryGetValue(identity, out handle); } return(handle); }