|
|
@@ -104,16 +104,15 @@ namespace ET
|
|
|
public void Remove(int id)
|
|
|
{
|
|
|
Fiber fiber = this.Get(id);
|
|
|
- fiber.ThreadSynchronizationContext.Post(()=>{fiber.Dispose();});
|
|
|
- // 这里不能dispose,因为有可能fiber还在运行,会出现线程竞争
|
|
|
- //fiber.Dispose();
|
|
|
- }
|
|
|
-
|
|
|
- internal void RemoveReal(int id)
|
|
|
- {
|
|
|
- this.fibers.Remove(id, out _);
|
|
|
- // 这里不能dispose,因为有可能fiber还在运行,会出现线程竞争
|
|
|
- //fiber.Dispose();
|
|
|
+
|
|
|
+ // 要扔到fiber线程执行,否则会出现线程竞争
|
|
|
+ fiber.ThreadSynchronizationContext.Post(() =>
|
|
|
+ {
|
|
|
+ if (this.fibers.Remove(id, out Fiber f))
|
|
|
+ {
|
|
|
+ f.Dispose();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
// 不允许外部调用,容易出现多线程问题, 只能通过消息通信,不允许直接获取其它Fiber引用
|