mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 05:23:55 +08:00
优化:优化播放逻辑去除多个方法共享属性导致的逻辑错误
This commit is contained in:
@@ -7,9 +7,16 @@ export default class BlockingQueue {
|
|||||||
#emptyResolve = null;
|
#emptyResolve = null;
|
||||||
|
|
||||||
/* 生产者:把数据塞进去 */
|
/* 生产者:把数据塞进去 */
|
||||||
enqueue(item) {
|
enqueue(item, ...restItems) {
|
||||||
this.#items.push(item);
|
if (restItems.length === 0) {
|
||||||
|
this.#items.push(item);
|
||||||
|
}
|
||||||
|
// 如果有额外参数,批量处理所有项
|
||||||
|
else {
|
||||||
|
const items = [item, ...restItems].filter(i => i);
|
||||||
|
if (items.length === 0) return;
|
||||||
|
this.#items.push(...items);
|
||||||
|
}
|
||||||
// 若有空队列闸门,一次性放行所有等待者
|
// 若有空队列闸门,一次性放行所有等待者
|
||||||
if (this.#emptyResolve) {
|
if (this.#emptyResolve) {
|
||||||
this.#emptyResolve();
|
this.#emptyResolve();
|
||||||
|
|||||||
+1515
-1451
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user