Skip to content

Commit

Permalink
docs: 添加 await new Sleep(0) 注释说明
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohappy committed Feb 27, 2025
1 parent edd3612 commit dee8098
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion site/docs/demo/audio-decode-wasm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ async function decode(log: (v: string) => void) {
if (stop) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}
await decoder.flush()
Expand Down
2 changes: 2 additions & 0 deletions site/docs/demo/audio-encode-wasm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ async function encode(log: (v: string) => void) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}

Expand Down
2 changes: 2 additions & 0 deletions site/docs/demo/audio-encode-webcodecs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ async function encode(log: (v: string) => void) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}

Expand Down
3 changes: 2 additions & 1 deletion site/docs/demo/demux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ async function demuxFile(log: (v: string) => void) {
if (stop) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}
iformatContext.destroy()
Expand Down
2 changes: 2 additions & 0 deletions site/docs/demo/video-decode-wasm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ async function decode(log: (v: string) => void) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}
await decoder.flush()
Expand Down
2 changes: 2 additions & 0 deletions site/docs/demo/video-encode-wasm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ async function encode(log: (v: string) => void) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}
await decoder.flush()
Expand Down
2 changes: 2 additions & 0 deletions site/docs/demo/video-encode-webcodecs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ async function encode(log: (v: string) => void) {
break
}

// 这里是为了防止卡死主线程加的 sleep
// 你可以将逻辑放入 worker 或定时任务中去掉此处
await new Sleep(0)
}
await decoder.flush()
Expand Down

0 comments on commit dee8098

Please sign in to comment.