WO2020253776A1 - 基于定时器的任务处理方法、装置及电子设备 - Google Patents

基于定时器的任务处理方法、装置及电子设备 Download PDF

Info

Publication number
WO2020253776A1
WO2020253776A1 PCT/CN2020/096809 CN2020096809W WO2020253776A1 WO 2020253776 A1 WO2020253776 A1 WO 2020253776A1 CN 2020096809 W CN2020096809 W CN 2020096809W WO 2020253776 A1 WO2020253776 A1 WO 2020253776A1
Authority
WO
WIPO (PCT)
Prior art keywords
timer
time
countdown
linked list
timer object
Prior art date
Application number
PCT/CN2020/096809
Other languages
English (en)
French (fr)
Inventor
赵命华
Original Assignee
深圳市道通科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市道通科技股份有限公司 filed Critical 深圳市道通科技股份有限公司
Publication of WO2020253776A1 publication Critical patent/WO2020253776A1/zh
Priority to US17/533,100 priority Critical patent/US20220100561A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • G06F9/4887Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues involving deadlines, e.g. rate based, periodic
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution

Definitions

  • This application relates to the field of computer technology, and in particular to a timer-based task processing method, device and electronic equipment.
  • timers are frequently used in business logic to complete specific functions.
  • the function of timers is to control the time interval for software to wait for an event to occur.
  • Timers are generally divided into hardware timers and Software timer.
  • the hardware timer generates timing events through interrupts, and the software timer is implemented through time slices.
  • queues are usually used to manage and control timers, including single-queue and double-queue.
  • the inventor found that the related technology has at least the following problems: when task processing is triggered by a timer, the efficiency is low, and there is an error accumulation effect, which causes the problem of inaccurate timing.
  • the technical problem to be solved by the present invention is to provide a timer-based task processing method, device and electronic equipment to solve the technical problems of low efficiency and inaccurate timing in related technologies.
  • a timer-based task processing method includes:
  • the obtaining the countdown time of the timer object according to the first timer includes:
  • the method further includes:
  • the sorting the multiple timer objects in the linked list specifically includes:
  • the multiple timer objects are sorted in the linked list in a time sequence.
  • the method further includes: inserting a new timer object in the linked list.
  • the method further includes: deleting the timer object in the linked list.
  • a timer-based task processing device includes:
  • the first obtaining module is configured to obtain the countdown time of the timer object according to the first timer
  • the first processing module is configured to control the second timer to count down according to the countdown time, and when the countdown ends, process the task corresponding to the timer object.
  • the first obtaining module is specifically configured to:
  • the device further includes:
  • a sorting module for sorting the multiple timer objects in the linked list
  • the second acquiring module is configured to acquire the countdown time of the first timer object in the linked list according to the first timer;
  • the second processing module is configured to control the second timer to count down according to the countdown time of the first timer object, and when the countdown ends, process the task corresponding to the first timer object, and repeat The above steps of acquiring the countdown time and counting down according to the countdown time until the tasks corresponding to all timer objects in the linked list are processed, and the next cycle continues.
  • the sorting module is specifically configured to:
  • the multiple timer objects are sorted in the linked list in a time sequence.
  • the device further includes:
  • the insert module is used to insert a new timer object in the linked list.
  • the device further includes:
  • the delete module is used to delete the timer object in the linked list.
  • an electronic device including: a first timer for acquiring the countdown time of a timer object; a second timer for counting down according to the countdown time; at least one process And a memory communicatively connected with the at least one processor; wherein the first timer and the second timer are both coupled to the processor; the memory stores the memory that can be processed by the at least one The instructions are executed by the processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the method as described above.
  • two timers are set, the first timer is used to obtain the countdown time of the timer object, and then the second timer is used to count down according to the countdown time, and the task corresponding to the timer object is processed when the countdown ends.
  • This embodiment uses two timers to control the timer object, which improves the operation efficiency of the timer object, reduces the error accumulation effect, and improves the timing accuracy.
  • Figure 1 is a flowchart of a timer-based task processing method provided by an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for obtaining the countdown time of a timer object according to a first timer according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a timer-based task processing method provided by another embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of a task processing for multiple timer objects according to an embodiment of the present invention
  • FIG. 5 is a schematic structural diagram of a timer-based task processing device provided by an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of the hardware structure of an electronic device for executing a timer-based task processing method provided by an embodiment of the present invention.
  • the embodiment of the present invention provides a timer-based task processing method and device.
  • the principle of the invention of the timer-based task processing method and device is:
  • the embodiment of the present invention uses two hardware timers to process tasks corresponding to the timer object.
  • the first timer is used to generate an absolute time stamp.
  • the absolute time stamp is the time reference of the entire timing system and can be understood as the system time.
  • the second timer is used to count down according to the countdown time of the timer object, and the countdown time of the timer object is calculated according to the absolute timestamp and the preset timing moment.
  • the absolute time stamp is generated when the first timer starts, and the second timer starts counting down according to the countdown time of the timer object.
  • the The second timer When the preset timing moment is reached, the The second timer generates a timing interrupt, and the task corresponding to the callback function in the timer object is processed at this time.
  • the first timer continues to obtain the current absolute time stamp, calculates the countdown time of the second timer object according to the current absolute time stamp and the preset timing time corresponding to the second timer object, and then the second timer object The timer counts down the second timer object according to the countdown time, and when the countdown ends, the task corresponding to the callback function in the second timer object is processed, and so on, until all timer objects are processed.
  • timer objects may be stored in a linked list, and each timer object may be sorted according to preset timings to form a circular linked list.
  • the above-mentioned two hardware timers are used to set timed events, and multiple timed events can be created, and the system only needs to access the timer object that reaches the timed time, instead of accessing all the timer objects at every moment. Reduce the occupancy rate of the CPU and improve the operation efficiency of the timer object. In addition, the embodiment of the present invention does not generate cumulative errors, and improves the timing accuracy.
  • FIG. 1 is a flowchart of a timer-based task processing method provided by an embodiment of the present invention. As shown in FIG. 1, the method includes:
  • Step S101 Acquire the countdown time of the timer object according to the first timer.
  • the first timer may specifically be a hardware timer.
  • the timer object includes a relative timing time, an absolute timing moment, a timing callback function, the previous timer object and the next timer object.
  • the relative timing time is a time relative to the absolute time stamp and the absolute timing time, and the relative timing time is equal to the absolute timing time minus the absolute time stamp.
  • the absolute timing moment is a preset time point, which can be customized by the system, or the absolute timing moment can be set by the user according to personal preferences, wherein when the absolute timing moment is reached When the time, the event corresponding to the timer object is triggered.
  • the timing callback function may be empty, and the timing callback function may also include at least one task event.
  • the task event can be specifically set according to the corresponding application scenario, for example, the task event is ringing, meeting notification reminder, etc. .
  • the former timer object and the latter timer object are two timer objects adjacent to the current timer object.
  • the first timer The timer object before the object is the timer object at the end of the circular linked list, and the timer object after the first timer object is the second timer object.
  • the timer object before the first timer object is empty, and the timer object after the first timer object is the second timer object.
  • the countdown time refers to the time used to trigger the execution of the task corresponding to the timing callback function.
  • the countdown time is used by the second timer, and the second timer counts down according to the countdown time.
  • the countdown ends Execute the task corresponding to the timing callback function in the timer object.
  • obtaining the countdown time of the timer object according to the first timer specifically includes the following steps:
  • Step S1011 obtain an absolute time stamp according to the first timer.
  • the absolute time stamp refers to the system time of the entire timing system.
  • the first timer can read the absolute time stamp through a preset interface.
  • the absolute timestamp may be acquired when the first timer starts.
  • Step S1012 Obtain the preset timing of the timer object.
  • the preset timing time is also the above-mentioned absolute timing time.
  • the preset timing time is a preset time point.
  • the preset timing time can be customized by the system, or it can be set by the user according to personal preferences.
  • the preset timing is set, wherein when the preset timing is reached, the task corresponding to the timer object is executed.
  • Step S1013 Perform a difference calculation between the preset timing and the absolute time stamp, and the obtained difference is the countdown time of the timer object.
  • countdown time preset timing time-absolute time stamp.
  • the absolute timestamp may be obtained multiple times through the first timer within a preset time, so as to obtain multiple countdown times, and then calculate the average value of the multiple countdown times , The average value is the countdown time. This improves the accuracy of the countdown time.
  • Step S102 Control the second timer to count down according to the countdown time, and when the countdown ends, process the task corresponding to the timer object.
  • the second timer may also be a hardware timer.
  • the second timer When the first timer is started, the second timer also starts to count down according to the countdown time. Whether the countdown is over can be judged by detecting whether the second timer generates an interrupt. When the second timer is interrupted, the countdown is over. At this time, the callback function corresponding to the timer object is processed. task.
  • the current absolute timestamp is 10000 (the timestamp is a value accumulated at a fixed time), and the unit is assumed to be: microseconds, and the preset timing for acquiring the timer object Ta1 is 15000, then
  • the countdown time of the timer object Ta1 is 5000 microseconds, and the timer 2 also starts to count down when the timer 1 is turned on.
  • the task corresponding to the timer object Ta1 is processed, which is specifically a timer The task corresponding to the timing callback function in the object Ta1.
  • the embodiment of the present invention provides a timer-based task processing method.
  • the method sets two timers to trigger the execution of the task corresponding to the timer object.
  • the time reference is generated by timer 1, namely Absolute timestamp, each time the timing (ie countdown time) is set is calculated based on the absolute timing time and the absolute timestamp.
  • the embodiment of the present invention does not produce cumulative error effects, thereby improving timing accuracy Rate, improve the operating efficiency of the timer object.
  • the method when there are multiple timer objects, the method includes:
  • Step S201 Sort the multiple timer objects in a linked list.
  • the linked list may specifically be a circular linked list.
  • other data structures such as queues, singly linked lists, and doubly linked lists can also be used to store the timer object.
  • the sorting of the multiple timer objects in the linked list may be specifically based on the sequence of the preset timings corresponding to the timer objects.
  • the circular linked list includes timer objects Ta1, Ta2, Ta3, and timer object Ta1.
  • the preset timing time of the timer object Ta2 is 15000
  • the preset timing time of the timer object Ta2 is 20000
  • the preset timing time of the timer object Ta3 is 40,000, and so on.
  • Step S202 Obtain the absolute timestamp of the first timer object in the linked list according to the first timer;
  • Step S203 Obtain the preset timing of the first timer object
  • Step S204 Perform a difference calculation between the preset timing time of the first timer object and the absolute time stamp of the first timer object, and the obtained difference is the value of the first timer object.
  • the steps S202 to S204 can be specifically referred to the above-mentioned embodiment, which will not be repeated here.
  • Step S205 Control the second timer to count down according to the countdown time, and when the countdown ends, execute the task corresponding to the first timer object;
  • Step S206 Determine whether all timer objects in the linked list have been processed. If not, repeat the above steps S202 to S205 until all tasks corresponding to the timer objects are executed.
  • the corresponding absolute time stamp and the corresponding preset timing time are obtained according to the currently processed timer object.
  • the absolute time stamp is different, and different timer objects have different preset timings.
  • multiple groups of timing systems including two timers can be set up to process the multiple timers with the same preset timing time.
  • Figure 4 shows five timer objects, namely Moment_1, Moment_2, Moment_3, Moment_4 and Moment_5, where the previous timer object of Moment_1 is Moment_5, and the next timer object of Moment_5 It's Moment_1.
  • first obtain the countdown time of Moment_1 through the first timer that is, obtain the absolute time stamp of Moment_1 according to the first timer, and obtain the preset timing of Moment_1, and subtract the absolute time from the preset timing.
  • the task corresponding to Moment_1 is processed.
  • the absolute time stamp of Moment_2 is obtained through the first timer. And get the preset timing of Moment_2, and then calculate the countdown time of Moment_2.
  • the second timer counts down according to the countdown time of Moment_2.
  • the task corresponding to Moment_2 is processed, and so on, until the task corresponding to Moment_5 is processed , And then enter the next cycle from Moment_1.
  • the embodiment of the present invention processes multiple timer objects based on a circular linked list and two timers. In the process of triggering the timing event of each timer object, there is no redundant traversal timer operation, and no accumulation is generated. The error effect improves the timing accuracy and improves the operating efficiency of the timer object.
  • the method further includes: inserting a new timer object in the linked list.
  • the inserted new timer object can correspond to the new task.
  • the address of the linked list object and the absolute timing time corresponding to the timer object (that is, the preset timing time) can be stored in a two-dimensional array.
  • the two-dimensional array is sorted according to the order of the absolute timing and then the dichotomy
  • the corresponding timer object is searched in the two-dimensional array in the method.
  • this method can significantly improve the search efficiency of the timer object.
  • the timer object can also be inserted through other methods.
  • the method further includes: deleting the timer object from the linked list.
  • deleting a timer object you can also store the address of the linked list object and the absolute timing time corresponding to the timer object (that is, the preset timing time) into a two-dimensional array, and the two-dimensional array is sorted according to the order of the absolute timing time. , And then find the timer object to be deleted in the two-dimensional array by dichotomy, and update the mapping relationship between the timer object before and after the timer object in the linked list at the same time.
  • FIG. 5 is a schematic structural diagram of a timer-based task processing device provided by an embodiment of the present invention.
  • the device 30 includes a first obtaining module 31 and a first processing module 32.
  • the first obtaining module 31 is used to obtain the countdown time of the timer object according to the first timer; the first processing module 32 is used to control the second timer to count down according to the countdown time, and the When the countdown ends, the task corresponding to the timer object is processed.
  • the first obtaining module 31 is specifically configured to: obtain an absolute time stamp according to a first timer; obtain a preset timing moment of a timer object; and compare the preset timing moment with the absolute time The difference calculation is performed by stamping, and the obtained difference is the countdown time of the timer object.
  • the apparatus 30 further includes a sorting module 33, a second obtaining module 34, and a second processing module 35.
  • the sorting module 33 is configured to sort the multiple timer objects in the linked list;
  • the second obtaining module 34 is configured to obtain the first timing in the linked list according to the first timer The countdown time of the timer object;
  • the second processing module 35 is used to control the second timer to count down according to the countdown time of the first timer object, and when the countdown ends, process the first Repeat the steps of obtaining the countdown time and counting down according to the countdown time for tasks corresponding to each timer object, until the tasks corresponding to all timer objects in the linked list are processed, and the next cycle continues.
  • the sorting module 33 is specifically configured to sort the plurality of timer objects in a linked list in a time sequence according to the preset timing moments respectively corresponding to the plurality of timer objects.
  • the device 30 further includes an insertion module 36 and a deletion module 37.
  • the insertion module 36 is used to insert a new timer object in the linked list.
  • the deletion module 37 is configured to delete the timer object in the linked list.
  • the embodiment of the present invention provides a timer-based task processing device.
  • the device sets two timers to trigger the execution of tasks corresponding to the timer object.
  • timer 1 In the process of triggering a timed event, timer 1 generates a time reference, namely Absolute time stamp, each time you set the timing (ie, countdown time) is calculated based on the absolute timing time and absolute time stamp.
  • the embodiment of the present invention processes multiple timer objects based on a circular linked list and two timers. In the process of triggering the timing event of each timer object, there is no redundancy. The operation of traversing the timer will not produce cumulative error effects, thereby improving the timing accuracy and improving the operating efficiency of the timer object.
  • FIG. 6 is a schematic diagram of the hardware structure of an electronic device for executing a timer-based task processing method according to an embodiment of the present invention.
  • the electronic device 40 includes: a first timer 41, The second timer 42, one or more processors 43, and the memory 44.
  • a processor 43 is taken as an example.
  • the first timer 41 is used to obtain the countdown time of the timer object, and the countdown time is calculated according to the absolute time stamp and the absolute timing moment of the timer object.
  • the second timer 42 is used to count down the timer object according to the countdown time.
  • first timer 41 and the second timer 42 are both coupled to the processor.
  • the processor 43 and the memory 44 may be connected by a bus or in other ways.
  • the connection by a bus is taken as an example.
  • the memory 44 as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs and modules, such as the timer-based task processing method in the embodiments of the present invention Corresponding program instructions/modules (for example, the first acquisition module 31 and the first processing module 32 shown in FIG. 5, etc.).
  • the processor 43 executes various functional applications and data processing of the server by running non-volatile software programs, instructions, and modules stored in the memory 44, that is, realizing the timer-based task processing method in the foregoing method embodiment.
  • the memory 44 may include a storage program area and a storage data area.
  • the storage program area may store an operating system and an application program required by at least one function; the storage data area may store data created according to the use of a timer-based task processing device. Wait.
  • the memory 44 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
  • the memory 44 may optionally include memories remotely provided with respect to the processor 43, and these remote memories may be connected to a timer-based task processing device through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
  • the one or more modules are stored in the memory 44, and when executed by the one or more processors 43, the timer-based task processing method in any of the foregoing method embodiments is executed, for example, the foregoing description is executed
  • the method steps S101 to S102 in FIG. 1, the method steps S1011 to S1013 in FIG. 2, and the method steps S201 to S206 in FIG. 3 implement the functions of the modules 31-37 in FIG. 5.
  • the electronic devices in the embodiments of the present invention exist in various forms, including but not limited to mobile robots, and other electronic devices with data interaction functions.
  • the embodiment of the present invention provides a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by an electronic device.
  • the timer-based task processing method in FIG. for example, executes the steps S101 to S102 in the method described above in FIG. 1, the steps S1011 to S1013 in the method in FIG. 2, and the steps S201 to S206 in the method in FIG. Functions of modules 31-37 in Figure 5.
  • the embodiment of the present invention provides a computer program product, including a calculation program stored on a non-volatile computer-readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, cause the
  • the computer executes the timer-based task processing method in any of the above method embodiments, for example, executes the method steps S101 to S102 in FIG. 1 described above, the method steps S1011 to S1013 in FIG. 2, and the method in FIG. 3 Steps S201 to S206 implement the functions of modules 31-37 in FIG. 5.
  • the device embodiments described above are merely illustrative.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each implementation manner can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware.
  • a person of ordinary skill in the art can understand that all or part of the processes in the method of the foregoing embodiments can be implemented by instructing relevant hardware through a computer program.
  • the program can be stored in a computer readable storage medium. When executed, it may include the processes of the above-mentioned method embodiments.
  • the storage medium may be a magnetic disk, an optical disc, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)
  • Measurement Of Predetermined Time Intervals (AREA)

Abstract

本发明涉及计算机技术领域,尤其涉及一种基于定时器的任务处理方法、装置及电子设备。该方法包括:根据第一定时器获取定时器对象的倒计时时间;控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。该实施方式通过两个定时器来控制定时器对象,提高了定时器对象的操作效率,降低了误差累计效应,提高了定时准确率。

Description

基于定时器的任务处理方法、装置及电子设备
本申请要求于2019年6月19日提交中国专利局、申请号为201910530881.0、申请名称为“基于定时器的任务处理方法、装置及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种基于定时器的任务处理方法、装置及电子设备。
背景技术
在基于实时操作系统进行嵌入式软件开发时,业务逻辑中会频繁使用到定时器来完成特定功能,定时器的作用就是控制软件等待某事件发生的时间间隔,定时器一般分为硬件定时器和软件定时器。硬件定时器通过中断产生定时事件,软件定时器通过时间片的方式实现。在具体实现时,通常会采用队列对定时器进行管理控制,包括单队列和双队列。
发明人在实现本发明的过程中发现相关技术至少存在以下问题:在通过定时器触发任务处理时,效率低,并且存在误差累计效应,从而造成定时不准的问题。
发明内容
本发明要解决的技术问题是提供一种基于定时器的任务处理方法、装置及电子设备,解决相关技术存在效率低并且定时不准的技术问题。
本发明实施例的一个方面,提供一种基于定时器的任务处理方法,所述方法包括:
根据第一定时器获取定时器对象的倒计时时间;
控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
可选地,所述根据第一定时器获取定时器对象的倒计时时间,包括:
根据第一定时器获取绝对时间戳;
获取定时器对象的预设定时时刻;
将所述预设定时时刻与所述绝对时间戳进行求差运算,所得到的差值为所述定时器对象的倒计时时间。
可选地,当定时器对象包含多个时,所述方法还包括:
将所述多个定时器对象在链表中进行排序;
根据所述第一定时器获取所述链表中第一个定时器对象的倒计时时间;
控制所述第二定时器根据所述第一个定时器对象的倒计时时间进行倒计时,在所述倒计时结束时,处理所述第一个定时器对象对应的任务,重复上述 获取所述倒计时时间以及根据所述倒计时时间进行倒计时的步骤,直至处理完毕所述链表中的全部定时器对象对应的任务,继续下一次循环。
可选地,所述将所述多个定时器对象在链表中进行排序具体包括:
根据所述多个定时器对象分别对应的预设定时时刻,按照时间先后顺序,将所述多个定时器对象在链表中进行排序。
可选地,所述方法还包括:在所述链表中插入新的定时器对象。
可选地,所述方法还包括:在所述链表中删除所述定时器对象。
本发明实施例的另一个方面,提供一种基于定时器的任务处理装置,所述装置包括:
第一获取模块,用于根据第一定时器获取定时器对象的倒计时时间;
第一处理模块,用于控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
可选地,所述第一获取模块具体用于:
根据第一定时器获取绝对时间戳;
获取定时器对象的预设定时时刻;
将所述预设定时时刻与所述绝对时间戳进行求差运算,得到的差值为所述定时器对象的倒计时时间。
可选地,当定时器对象包含多个时,所述装置还包括:
排序模块,用于在链表中将所述多个定时器对象进行排序;
第二获取模块,用于根据所述第一定时器获取所述链表中第一个定时器对象的倒计时时间;
第二处理模块,用于控制所述第二定时器根据所述第一个定时器对象的倒计时时间进行倒计时,在所述倒计时结束时,处理所述第一个定时器对象对应的任务,重复上述获取所述倒计时时间以及根据所述倒计时时间进行倒计时的步骤,直至处理完毕所述链表中的全部定时器对象对应的任务,继续下一次循环。
可选地,所述排序模块具体用于:
根据所述多个定时器对象分别对应的预设定时时刻,按照时间先后顺序,将所述多个定时器对象在链表中进行排序。
可选地,所述装置还包括:
插入模块,用于在所述链表中插入新的定时器对象。
可选地,所述装置还包括:
删除模块,用于在所述链表中删除所述定时器对象。
本发明实施例的再一个方面,提供一种电子设备,包括:第一定时器,用于获取定时器对象的倒计时时间;第二定时器,用于根据所述倒计时时间进行倒计时;至少一个处理器;以及与所述至少一个处理器通信连接的存储器;其中,所述第一定时器和所述第二定时器均耦合至所述处理器;所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执 行,以使所述至少一个处理器能够执行如上所述的方法。
在本发明实施例中,设置两个定时器,通过第一定时器获取定时器对象的倒计时时间,然后通过第二定时器根据该倒计时时间进行倒计时,在倒计时结束时处理定时器对象对应的任务。该实施方式通过两个定时器来控制定时器对象,提高了定时器对象的操作效率,降低了误差累计效应,提高了定时准确率。
附图说明
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。
图1是本发明实施例提供的一种基于定时器的任务处理方法的流程图;
图2是本发明实施例提供中根据第一定时器获取定时器对象的倒计时时间的方法的流程图;
图3是本发明另一实施例提供的一种基于定时器的任务处理方法的流程图;
图4是本发明实施例提供的一种对多个定时器对象进行任务处理时的流程示意图;
图5是本发明实施例提供的一种基于定时器的任务处理装置的结构示意图;
图6是本发明实施例提供的执行基于定时器的任务处理方法的一种电子设备的硬件结构示意图。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。
需要说明的是,如果不冲突,本发明实施例中的各个特征可以相互组合,均在本发明的保护范围之内。另外,虽然在装置示意图中进行了功能模块的划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置示意图中的模块划分,或流程图中的顺序执行所示出或描述的步骤。
本发明实施例提供了一种基于定时器的任务处理方法和装置,所述基于定时器的任务处理方法和装置的发明原理为:
本发明实施例采用两个硬件定时器来处理定时器对象对应的任务。其中,第一定时器用于产生绝对时间戳,该绝对时间戳是整个定时系统的时间基准,可以理解为系统时间。第二定时器用于根据定时器对象的倒计时时间进行倒计时,所述定时器对象的倒计时时间是根据所述绝对时间戳和预设定时时刻计算得到的。
在实际应用过程中,第一定时器启动时就产生所述绝对时间戳,所述第二定时器根据定时器对象的倒计时时间开始倒计时,当到达设定的所述预设定时时刻时,所述第二定时器产生定时中断,此时处理所述定时器对象中的回调函数对应的任务。与此同时,第一定时器继续获取当前的绝对时间戳,根据所述当前的绝对时间戳和第二定时器对象对应的预设定时时刻计算得到第二定时器对象的倒计时时间,然后第二定时器根据该倒计时时间对所述第二定时器对象进行倒计时,在倒计时结束时,处理所述第二定时器对象中的回调函数对应的任务,依次类推,直到处理完毕全部定时器对象。
其中,上述定时器对象可以存储在链表中,可以根据预设定时时刻对各个定时器对象进行排序,形成循环链表。
上述通过两个硬件定时器来设置定时事件,并且可以创建多个定时事件,而且系统只需访问到达定时时间的定时器对象,而不需要每个时刻都访问所有的定时器对象,极大的减少了CPU的占用率,提高了定时器对象的操作效率。另外,本发明实施例不会产生累积误差,提高了定时准确率。
请参阅图1,图1是本发明实施例提供的一种基于定时器的任务处理方法的流程图,如图1所示,该方法包括:
步骤S101、根据第一定时器获取定时器对象的倒计时时间。
其中,所述第一定时器具体可以为硬件定时器。
其中,所述定时器对象包括相对定时时间、绝对定时时刻、定时回调函数、前一个定时器对象以及后一个定时器对象。所述相对定时时间是相对于绝对时间戳和所述绝对定时时刻的一个时间,所述相对定时时间等于所述绝对定时时刻减去所述绝对时间戳。所述绝对定时时刻是预先设定好的一个时间点,可以由系统自定义设定该绝对定时时刻,也可以由用户根据个人喜好设定该绝对定时时刻,其中,当到达所述绝对定时时刻时,则触发所述定时器对象对应的事件。所述定时回调函数可以为空,所述定时回调函数也可以包括至少一个任务事件,该任务事件具体的可以根据相应的应用场景来设置,比如,该任务事件为响铃、会议通知提醒等等。所述前一个定时器对象和所述后一个定时器对象即是与当前的定时器对象相邻的两个定时器对象,比如,当多个定时器对象组成循环链表时,第一个定时器对象的前一个定时器对象为所述循环链表最末端的定时器对象,第一个定时器对象的后一个定时器对象为第二个定时器对象。又比如,当多个定时器对象组成单链表时,第一个定时器对象的前一个定时器对象为空,第一个定时器对象的后一个定时器对象为第二个定时器对象。
其中,所述倒计时时间指的是用来触发开始执行定时回调函数对应的任务的时间,该倒计时时间被第二定时器所使用,由第二定时器根据该倒计时时间进行倒计时,在倒计时结束时,执行所述定时器对象中定时回调函数对应的任务。
其中,请参阅图2,根据第一定时器获取定时器对象的倒计时时间具体包括以下步骤:
步骤S1011、根据第一定时器获取绝对时间戳。
所述绝对时间戳指的是整个定时系统的系统时间。第一定时器可以通过预设的接口读取所述绝对时间戳。可以在所述第一定时器启动时即获取所述绝对时间戳。
步骤S1012、获取定时器对象的预设定时时刻。
所述预设定时时刻也即是上述绝对定时时刻,所述预设定时时刻是预先设定好的一个时间点,可以由系统自定义设定该预设定时时刻,也可以由用户根据个人喜好设定该预设定时时刻,其中,当到达所述预设定时时刻时,则执行所述定时器对象对应的任务。
步骤S1013、将所述预设定时时刻与所述绝对时间戳进行求差运算,所得到的差值为所述定时器对象的倒计时时间。
其中,倒计时时间=预设定时时刻-绝对时间戳。
在其他一些可选的实施例中,可以在预设时间内通过所述第一定时器多次获取所述绝对时间戳,从而得到多个倒计时时间,然后求取该多个倒计时时间的平均值,该平均值即是所述倒计时时间。由此,提高倒计时时间的精确度。
步骤S102、控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
所述第二定时器也可以为硬件定时器。在所述第一定时器开启时,所述第二定时器也开始根据所述倒计时时间进行倒计时。所述倒计时是否结束可以通过检测第二定时器是否产生中断来进行判断,当检测到所述第二定时器中断时,则所述倒计时结束,此时处理所述定时器对象中回调函数对应的任务。
下面通过一个例子具体说明上述过程。例如,定时器1开启,获取当前的绝对时间戳为10000(时间戳是一个固定时间累加一次的数值),这里假设单位是:微秒,获取定时器对象Ta1的预设定时时刻为15000,那么定时器对象Ta1的倒计时时间为5000微秒,定时器2在定时器1开启时也开始倒计时,倒计时5000微秒结束时,即处理所述定时器对象Ta1对应的任务,该任务具体是定时器对象Ta1中定时回调函数对应的任务。
本发明实施例提供了一种基于定时器的任务处理方法,该方法设置两个定时器来触发执行定时器对象对应的任务,在触发定时事件的过程中,通过定时器1产生时间基准,即绝对时间戳,每次设定定时(即倒计时时间)都是根据绝对定时时刻和绝对时间戳来计算,相比较于现有技术,本发明实施例不会产生累积误差效应,从而提高了定时准确率,提升了定时器对象的操作效率。
在其他一些可选的实施例中,请参阅图3,当定时器对象包含多个时,所述方法包括:
步骤S201、将所述多个定时器对象在链表中进行排序。
所述链表具体可以是循环链表。当然,还可以使用队列、单向链表、双向链表等其他数据结构来存储所述定时器对象。
所述多个定时器对象在链表中排序具体可以根据所述定时器对象对应的 预设定时时刻的先后来进行排序,比如,循环链表中包括定时器对象Ta1、Ta2、Ta3,定时器对象Ta1的预设定时时刻为15000,定时器对象Ta2的预设定时时刻为20000,定时器对象Ta3的预设定时时刻40000,等。
步骤S202、根据所述第一定时器获取所述链表中第一个定时器对象的绝对时间戳;
步骤S203、获取所述第一个定时器对象的预设定时时刻;
步骤S204、将所述第一个定时器对象的预设定时时刻与所述第一个定时器对象的绝对时间戳进行求差运算,所得到的差值为所述第一个定时器对象的倒计时时间;
由于获取所述绝对时间戳、所述预设定时时刻以及所述倒计时时间的步骤与上述实施例的构思相同,因此步骤S202至步骤S204具体可以参考上述实施例,在此不再赘述。
步骤S205、控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,执行所述第一个定时器对象对应的任务;
步骤S206、判断所述链表中的定时器对象是否全部处理完,若否,则重复执行上述步骤S202至步骤S205,直至执行完毕全部定时器对象对应的任务。
其中,在跳转执行所述步骤S202至步骤S205时,是根据当前处理的定时器对象去获取其对应的绝对时间戳和其对应的预设定时时刻的。在处理不同的定时器对象时,所述绝对时间戳是不相同的,并且不同的定时器对象其预设定时时刻也不同。当然,如果存在两个或者多个定时器对象的预设定时时刻相同时,可以基于上述原理,设置多组包含两个定时器的定时系统来处理所述多个预设定时时刻相同的定时器对象。
下面举例说明根据第一定时器和第二定时器对多个定时器对象进行处理的具体过程。例如,请参阅图4,图4中示出了5个定时器对象,分别是Moment_1、Moment_2、Moment_3、Moment_4以及Moment_5,其中,Moment_1的上一个定时器对象是Moment_5,Moment_5的下一个定时器对象是Moment_1。在进行任务处理时,首先通过第一定时器获取Moment_1的倒计时时间,即根据第一定时器获取Moment_1的绝对时间戳,并获取Moment_1的预设定时时刻,将该预设定时时刻减去该绝对时间戳,从而得到Moment_1的倒计时时间;然后,第二定时器根据该倒计时时间进行倒计时,在倒计时结束时,处理Moment_1对应的任务,与此同时,通过第一定时器获取Moment_2的绝对时间戳,并获取Moment_2的预设定时时刻,然后计算得到Moment_2的倒计时时间,第二定时器根据Moment_2的倒计时时间进行倒计时,在倒计时结束时,处理Moment_2对应的任务,依次类推,直至处理完Moment_5对应的任务,然后再从Moment_1开始进入下一次循环。
本发明实施例基于循环链表和两个定时器对多个定时器对象进行处理,在触发每个定时器对象的定时事件的过程中,不存在冗余遍历定时器的操作,也不会产生累积误差效应,从而提高了定时准确率,提升了定时器对象的操作效 率。
在其他一些可选的实施例中,基于上述图3,所述方法还包括:在所述链表中插入新的定时器对象。所插入的新的定时器对象可以对应新的任务。其中,可以将链表对象的地址和定时器对象对应的绝对定时时刻(也即是预设定时时刻)存入二维数组中,二维数组根据绝对定时时刻的先后顺序进行排序,然后通过二分法的方式在二维数组中查找对应的定时器对象,该方法相比较现有的查找定时器对象的方法,能明显提升定时器对象的查找效率。当然,在实际应用中还可以通过其他方法插入所述定时器对象。
在其他一些可选的实施例中,基于上述图3,所述方法还包括:在所述链表中删除所述定时器对象。删除定时器对象时,同样可以将链表对象的地址和定时器对象对应的绝对定时时刻(也即是预设定时时刻)存入二维数组中,二维数组根据绝对定时时刻的先后顺序进行排序,然后通过二分法的方式在二维数组中查找待删除的定时器对象,同时更新该定时器对象在链表中前后定时器对象的映射关系。
请参阅图5,图5是本发明实施例提供的一种基于定时器的任务处理装置的结构示意图,该装置30包括:第一获取模块31和第一处理模块32。
其中,所述第一获取模块31,用于根据第一定时器获取定时器对象的倒计时时间;所述第一处理模块32,用于控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
在本发明实施例中,所述第一获取模块31具体用于:根据第一定时器获取绝对时间戳;获取定时器对象的预设定时时刻;将所述预设定时时刻与所述绝对时间戳进行求差运算,得到的差值为所述定时器对象的倒计时时间。
在本发明的一些可选实施例中,同样请参阅图5,所述装置30还包括排序模块33、第二获取模块34以及第二处理模块35。其中,所述排序模块33,用于在链表中将所述多个定时器对象进行排序;所述第二获取模块34,用于根据所述第一定时器获取所述链表中第一个定时器对象的倒计时时间;所述第二处理模块35,用于控制所述第二定时器根据所述第一个定时器对象的倒计时时间进行倒计时,在所述倒计时结束时,处理所述第一个定时器对象对应的任务,重复上述获取所述倒计时时间以及根据所述倒计时时间进行倒计时的步骤,直至处理完毕所述链表中的全部定时器对象对应的任务,继续下一次循环。
其中,所述排序模块33具体用于:根据所述多个定时器对象分别对应的预设定时时刻,按照时间先后顺序,将所述多个定时器对象在链表中进行排序。
在本发明的一些可选实施例中,同样请参阅图5,所述装置30还包括插入模块36和删除模块37。所述插入模块36,用于在所述链表中插入新的定时器对象。所述删除模块37,用于在所述链表中删除所述定时器对象。
值得说明的是,上述装置内的模块、单元之间的信息交互、执行过程等内容,由于与本发明的方法实施例基于同一构思,具体内容可以参考本发明方法实施例中的叙述,此处不再赘述。
本发明实施例提供了一种基于定时器的任务处理装置,该装置设置两个定时器来触发执行定时器对象对应的任务,在触发定时事件的过程中,通过定时器1产生时间基准,即绝对时间戳,每次设定定时(即倒计时时间)都是根据绝对定时时刻和绝对时间戳来计算。另外,在存在多个定时器对象时,本发明实施例基于循环链表和两个定时器对多个定时器对象进行处理,在触发每个定时器对象的定时事件的过程中,不存在冗余遍历定时器的操作,也不会产生累积误差效应,从而提高了定时准确率,提升了定时器对象的操作效率。
请参阅图6,图6是本发明实施例提供的执行基于定时器的任务处理方法的一种电子设备的硬件结构示意图,如图6所示,该电子设备40包括:第一定时器41、第二定时器42、一个或多个处理器43以及存储器44。图5中以一个处理器43为例。
所述第一定时器41用于获取定时器对象的倒计时时间,所述倒计时时间是根据所述定时器对象的绝对时间戳和绝对定时时刻计算得到的。所述第二定时器42用于根据所述倒计时时间对所述定时器对象进行倒计时。
其中,所述第一定时器41和所述第二定时器42均耦合至所述处理器。
处理器43和存储器44可以通过总线或者其他方式连接,图6中以通过总线连接为例。
存储器44作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本发明实施例中的基于定时器的任务处理方法对应的程序指令/模块(例如,附图5所示的第一获取模块31和第一处理模块32等)。处理器43通过运行存储在存储器44中的非易失性软件程序、指令以及模块,从而执行服务器的各种功能应用以及数据处理,即实现上述方法实施例的基于定时器的任务处理方法。
存储器44可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据基于定时器的任务处理装置的使用所创建的数据等。此外,存储器44可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施例中,存储器44可选包括相对于处理器43远程设置的存储器,这些远程存储器可以通过网络连接至基于定时器的任务处理装置。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
所述一个或者多个模块存储在所述存储器44中,当被所述一个或者多个处理器43执行时,执行上述任意方法实施例中的基于定时器的任务处理方法,例如,执行以上描述的图1中的方法步骤S101至步骤S102,图2中的方法步骤S1011至步骤S1013,图3中的方法步骤S201至步骤S206,实现图5中的模块31-37的功能。
上述产品可执行本发明实施例所提供的方法,具备执行方法相应的功能模块和有益效果。未在本实施例中详尽描述的技术细节,可参见本发明实施例所 提供的方法。
本发明实施例的电子设备以多种形式存在,包括但不限于移动机器人,等其他具有数据交互功能的电子装置。
本发明实施例提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被电子设备执行上述任意方法实施例中的基于定时器的任务处理方法,例如,执行以上描述的图1中的方法步骤S101至步骤S102,图2中的方法步骤S1011至步骤S1013,图3中的方法步骤S201至步骤S206,实现图5中的模块31-37的功能。
本发明实施例提供了一种计算机程序产品,包括存储在非易失性计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时时,使所述计算机执行上述任意方法实施例中的基于定时器的任务处理方法,例如,执行以上描述的图1中的方法步骤S101至步骤S102,图2中的方法步骤S1011至步骤S1013,图3中的方法步骤S201至步骤S206,实现图5中的模块31-37的功能。
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
通过以上的实施方式的描述,本领域普通技术人员可以清楚地了解到各实施方式可借助软件加通用硬件平台的方式来实现,当然也可以通过硬件来实现。本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;在本发明的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,步骤可以以任意顺序实现,并存在如上所述的本发明的不同方面的许多其它变化,为了简明,它们没有在细节中提供;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (13)

  1. 一种基于定时器的任务处理方法,其特征在于,所述方法包括:
    根据第一定时器获取定时器对象的倒计时时间;
    控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
  2. 根据权利要求1所述的方法,其特征在于,所述根据第一定时器获取定时器对象的倒计时时间,包括:
    根据第一定时器获取绝对时间戳;
    获取定时器对象的预设定时时刻;
    将所述预设定时时刻与所述绝对时间戳进行求差运算,所得到的差值为所述定时器对象的倒计时时间。
  3. 根据权利要求1或2所述的方法,其特征在于,当定时器对象包含多个时,所述方法还包括:
    将所述多个定时器对象在链表中进行排序;
    根据所述第一定时器获取所述链表中第一个定时器对象的倒计时时间;
    控制所述第二定时器根据所述第一个定时器对象的倒计时时间进行倒计时,在所述倒计时结束时,处理所述第一个定时器对象对应的任务,重复上述获取所述倒计时时间以及根据所述倒计时时间进行倒计时的步骤,直至处理完毕所述链表中的全部定时器对象对应的任务,继续下一次循环。
  4. 根据权利要求3所述的方法,其特征在于,所述将所述多个定时器对象在链表中进行排序具体包括:
    根据所述多个定时器对象分别对应的预设定时时刻,按照时间先后顺序,将所述多个定时器对象在链表中进行排序。
  5. 根据权利要求3所述的方法,其特征在于,所述方法还包括:
    在所述链表中插入新的定时器对象。
  6. 根据权利要求3所述的方法,其特征在于,所述方法还包括:
    在所述链表中删除所述定时器对象。
  7. 一种基于定时器的任务处理装置,其特征在于,所述装置包括:
    第一获取模块,用于根据第一定时器获取定时器对象的倒计时时间;
    第一处理模块,用于控制第二定时器根据所述倒计时时间进行倒计时,在所述倒计时结束时,处理所述定时器对象对应的任务。
  8. 根据权利要求7所述的装置,其特征在于,所述第一获取模块具体用于:
    根据第一定时器获取绝对时间戳;
    获取定时器对象的预设定时时刻;
    将所述预设定时时刻与所述绝对时间戳进行求差运算,得到的差值为所述定时器对象的倒计时时间。
  9. 根据权利要求7或8所述的装置,其特征在于,当定时器对象包含多个时,所述装置还包括:
    排序模块,用于在链表中将所述多个定时器对象进行排序;
    第二获取模块,用于根据所述第一定时器获取所述链表中第一个定时器对象的倒计时时间;
    第二处理模块,用于控制所述第二定时器根据所述第一个定时器对象的倒计时时间进行倒计时,在所述倒计时结束时,处理所述第一个定时器对象对应的任务,重复上述获取所述倒计时时间以及根据所述倒计时时间进行倒计时的步骤,直至处理完毕所述链表中的全部定时器对象对应的任务,继续下一次循环。
  10. 根据权利要求9所述的装置,其特征在于,所述排序模块具体用于:
    根据所述多个定时器对象分别对应的预设定时时刻,按照时间先后顺序,将所述多个定时器对象在链表中进行排序。
  11. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    插入模块,用于在所述链表中插入新的定时器对象。
  12. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    删除模块,用于在所述链表中删除所述定时器对象。
  13. 一种电子设备,其特征在于,包括:
    第一定时器,用于获取定时器对象的倒计时时间;
    第二定时器,用于根据所述倒计时时间进行倒计时;
    至少一个处理器;以及
    与所述至少一个处理器通信连接的存储器;其中,
    所述第一定时器和所述第二定时器均耦合至所述处理器;
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1至6中任一项所述的方法。
PCT/CN2020/096809 2019-06-19 2020-06-18 基于定时器的任务处理方法、装置及电子设备 WO2020253776A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/533,100 US20220100561A1 (en) 2019-06-19 2021-11-22 Timer-based task processing method and apparatus and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910530881.0 2019-06-19
CN201910530881.0A CN110262883B (zh) 2019-06-19 2019-06-19 基于定时器的任务处理方法、装置及电子设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/533,100 Continuation US20220100561A1 (en) 2019-06-19 2021-11-22 Timer-based task processing method and apparatus and electronic device

Publications (1)

Publication Number Publication Date
WO2020253776A1 true WO2020253776A1 (zh) 2020-12-24

Family

ID=67919306

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/096809 WO2020253776A1 (zh) 2019-06-19 2020-06-18 基于定时器的任务处理方法、装置及电子设备

Country Status (3)

Country Link
US (1) US20220100561A1 (zh)
CN (1) CN110262883B (zh)
WO (1) WO2020253776A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110262883B (zh) * 2019-06-19 2021-08-24 深圳市道通合创新能源有限公司 基于定时器的任务处理方法、装置及电子设备
CN111083010B (zh) * 2019-12-17 2021-09-24 深圳市网心科技有限公司 一种测速方法、装置和计算机可读存储介质
US11868287B2 (en) 2020-12-17 2024-01-09 Micron Technology, Inc. Just-in-time (JIT) scheduler for memory subsystems
US20220197563A1 (en) * 2020-12-17 2022-06-23 Micron Technology, Inc. Qos traffic class latency model for just-in-time (jit) schedulers
CN112948071A (zh) * 2021-01-26 2021-06-11 北京达佳互联信息技术有限公司 时间信息的处理方法、装置、设备、存储介质及程序产品
CN113794740B (zh) * 2021-11-16 2022-03-11 亿海蓝(北京)数据技术股份公司 定时器控制方法及系统、可读存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1755614A (zh) * 2004-09-29 2006-04-05 华为技术有限公司 定时器的实现方法
CN1905492A (zh) * 2005-07-25 2007-01-31 大唐移动通信设备有限公司 一种多数据链路监测维护的方法
CN103473071A (zh) * 2013-09-24 2013-12-25 深圳市路通网络技术有限公司 软件定时器的实现方法和系统
CN103677976A (zh) * 2013-12-09 2014-03-26 大唐移动通信设备有限公司 一种基于时间轮定器的事件处理方法及装置
CN104834347A (zh) * 2015-04-29 2015-08-12 杭州东信捷峻科技有限公司 有利于低功耗的无累计误差的动态时长定时器实现方法
CN108241308A (zh) * 2017-12-08 2018-07-03 中国航空工业集团公司成都飞机设计研究所 一种基于分时分区嵌入式软件的运行时间控制方法
CN110262883A (zh) * 2019-06-19 2019-09-20 深圳市道通科技股份有限公司 基于定时器的任务处理方法、装置及电子设备

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1755614A (zh) * 2004-09-29 2006-04-05 华为技术有限公司 定时器的实现方法
CN1905492A (zh) * 2005-07-25 2007-01-31 大唐移动通信设备有限公司 一种多数据链路监测维护的方法
CN103473071A (zh) * 2013-09-24 2013-12-25 深圳市路通网络技术有限公司 软件定时器的实现方法和系统
CN103677976A (zh) * 2013-12-09 2014-03-26 大唐移动通信设备有限公司 一种基于时间轮定器的事件处理方法及装置
CN104834347A (zh) * 2015-04-29 2015-08-12 杭州东信捷峻科技有限公司 有利于低功耗的无累计误差的动态时长定时器实现方法
CN108241308A (zh) * 2017-12-08 2018-07-03 中国航空工业集团公司成都飞机设计研究所 一种基于分时分区嵌入式软件的运行时间控制方法
CN110262883A (zh) * 2019-06-19 2019-09-20 深圳市道通科技股份有限公司 基于定时器的任务处理方法、装置及电子设备

Also Published As

Publication number Publication date
CN110262883A (zh) 2019-09-20
CN110262883B (zh) 2021-08-24
US20220100561A1 (en) 2022-03-31

Similar Documents

Publication Publication Date Title
WO2020253776A1 (zh) 基于定时器的任务处理方法、装置及电子设备
JP5797855B2 (ja) ウイルススキャン方法及びウイルススキャン装置
CN107004010A (zh) 控制多数据库系统
US9015841B2 (en) Method and apparatus for virus scanning
US11934983B2 (en) Issue and trigger rebalancing in a ranked issue management system
CN109800204B (zh) 数据分配方法及相关产品
WO2019057193A1 (zh) 数据删除方法及分布式存储系统
US11531941B2 (en) Issue rank management in an issue tracking system
CN106202082B (zh) 组装基础数据缓存的方法及装置
US9875137B2 (en) Intelligent application back stack management
CN105279261A (zh) 动态可扩展数据库归档方法和系统
CN106886450A (zh) 任务调度方法和系统
CN115525631A (zh) 数据库数据迁移方法、装置、设备、存储介质
WO2023160608A1 (zh) 机器人的控制方法、装置、存储介质及机器人集群
US20160292747A1 (en) Method and apparatus for placing display information
CN109800069B (zh) 一种实现数据治理的方法及装置
US20180024723A1 (en) Synchronizing user input with a user interface
CN116483546B (zh) 分布式训练任务调度方法、装置、设备及存储介质
TWI475409B (zh) Data synchronization method and device
CN110865877B (zh) 一种任务请求的响应方法及设备
CN113268183B (zh) 一种列表页面倒计时显示方法及装置
US20150081647A1 (en) Server and method for updating data of server
CN104317906A (zh) Gps监控车台上报数据大规模入库的处理方法
CN114721876A (zh) 一种数据备份方法、装置、介质
CN107025096B (zh) 异步渲染模块的同步方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20826407

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20826407

Country of ref document: EP

Kind code of ref document: A1