Commit baa3c210 authored by Him188's avatar Him188

Use Channel.UNLIMITED as a default capacity for `CoroutineScope.incoming`

parent 4085ecbd
...@@ -160,13 +160,16 @@ inline fun <R> Bot.subscribeFriendMessages( ...@@ -160,13 +160,16 @@ inline fun <R> Bot.subscribeFriendMessages(
* *
* @param capacity 同 [Channel] 的参数, 参见 [Channel.Factory] 中的常量. * @param capacity 同 [Channel] 的参数, 参见 [Channel.Factory] 中的常量.
* *
* @see capacity 默认无限大小. 详见 [Channel.Factory] 中的常量 [Channel.UNLIMITED], [Channel.CONFLATED], [Channel.RENDEZVOUS].
* 请谨慎使用 [Channel.RENDEZVOUS]: 在 [Channel] 未被 [接收][Channel.receive] 时他将会阻塞事件处理
*
* @see subscribeFriendMessages * @see subscribeFriendMessages
* @see subscribeMessages * @see subscribeMessages
* @see subscribeGroupMessages * @see subscribeGroupMessages
*/ */
inline fun <reified E : Event> CoroutineScope.incoming( inline fun <reified E : Event> CoroutineScope.incoming(
coroutineContext: CoroutineContext = EmptyCoroutineContext, coroutineContext: CoroutineContext = EmptyCoroutineContext,
capacity: Int = Channel.RENDEZVOUS capacity: Int = Channel.UNLIMITED
): ReceiveChannel<E> { ): ReceiveChannel<E> {
return Channel<E>(capacity).apply { return Channel<E>(capacity).apply {
subscribeAlways<E>(coroutineContext) { subscribeAlways<E>(coroutineContext) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment