处理异步任务的方法及装置

By using thread-local storage variables and thread identifiers in the asynchronous task thread pool to dynamically match threads in the pool to execute asynchronous tasks, the problem of low execution efficiency of the thread pool is solved, and more efficient task processing is achieved.

CN113849279BActive Publication Date: 2026-07-17武汉斗鱼鱼乐网络科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
武汉斗鱼鱼乐网络科技有限公司
Filing Date
2020-06-26
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

Existing asynchronous task thread pools suffer from low execution efficiency, and the use of different threads for task submission and execution leads to high overhead from thread switching and context switching.

Method used

The current thread submitting the asynchronous task is determined by creating a thread-local storage variable in the thread pool. The current thread is then used to execute the task if it belongs to the thread pool based on the thread identifier. Otherwise, the target thread is determined from the thread pool and matched with the task type and the data value of each thread in the thread pool, thus avoiding unnecessary thread creation and switching.

Benefits of technology

It improves the execution efficiency of asynchronous tasks, reduces the overhead of thread switching and context switching, saves resources, and ensures that tasks are matched with suitable threads for processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849279B_ABST
    Figure CN113849279B_ABST
Patent Text Reader

Abstract

本发明涉及任务处理技术领域,尤其涉及处理异步任务的方法及装置。所述方法包括:当异步任务被投递到线程池后,在线程池中创建线程;通过线程局部存储变量确定投递异步任务的当前线程;基于线程身份标识符判断当前线程是否属于线程池;若属于,利用当前线程执行异步任务;若不属于,从线程池中确定出目标线程,利用目标线程执行异步任务;其中,从线程池中确定出目标线程,包括:基于消耗计算量确定异步任务的任务类型,以及基于异步任务数变量、切换次数变量和选择执行次数变量确定线程池中每个线程的数据值;若为计算类型,则将数据值大于或等于预设数据阈值的线程作为目标线程;若为读写类型,则将数据值小于预设数据阈值的线程作为目标线程。
Need to check novelty before this filing date? Find Prior Art