MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / taskWrapper

Function taskWrapper

entrypoints/utils/translateQueue.ts:28–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26 return new Promise((resolve, reject) => {
27 // 创建任务包装器,在任务完成后处理队列状态
28 const taskWrapper = async () => {
29
30 try {
31 // 执行实际的翻译任务
32 const result = await translationTask();
33 resolve(result);
34 return result;
35 } catch (error) {
36 reject(error);
37 throw error;
38 } finally {
39 // 无论成功失败,都需要减少活跃任务计数并处理队列
40 activeTranslations--;
41 processQueue();
42
43 }
44 };
45
46 // 将任务添加到队列
47 if (activeTranslations < getMaxConcurrentTranslations()) {

Callers 1

enqueueTranslationFunction · 0.85

Calls 2

translationTaskFunction · 0.85
processQueueFunction · 0.85

Tested by

no test coverage detected