38 lines
732 B
Markdown
38 lines
732 B
Markdown
|
|
# Event::ProcessUnsubscribes
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
void ProcessUnsubscribes();
|
||
|
|
```
|
||
|
|
|
||
|
|
处理积压的退订请求。
|
||
|
|
|
||
|
|
**描述**
|
||
|
|
|
||
|
|
手动处理待退订的回调,将其从订阅列表中移除。通常不需要手动调用,`Invoke` 会自动处理退订。但在某些场景下可能需要主动调用。
|
||
|
|
|
||
|
|
**复杂度:** O(n) 其中 n 为待退订数量
|
||
|
|
|
||
|
|
**示例:**
|
||
|
|
|
||
|
|
```cpp
|
||
|
|
#include <XCEngine/Core/Event.h>
|
||
|
|
|
||
|
|
Event<int> event;
|
||
|
|
|
||
|
|
// 订阅
|
||
|
|
uint64_t id = event.Subscribe([](int value) { });
|
||
|
|
|
||
|
|
// 退订请求入队
|
||
|
|
event.Unsubscribe(id);
|
||
|
|
|
||
|
|
// 主动处理退订
|
||
|
|
event.ProcessUnsubscribes();
|
||
|
|
|
||
|
|
// 此时事件列表中已无该回调
|
||
|
|
```
|
||
|
|
|
||
|
|
## 相关文档
|
||
|
|
|
||
|
|
- [Event 总览](event.md) - 返回类总览
|
||
|
|
- [Unsubscribe](Unsubscribe.md) - 退订事件
|