CN114691343A - Polling task execution method and device, computer equipment and readable storage medium - Google Patents

Polling task execution method and device, computer equipment and readable storage medium Download PDF

Info

Publication number
CN114691343A
CN114691343A CN202210618445.0A CN202210618445A CN114691343A CN 114691343 A CN114691343 A CN 114691343A CN 202210618445 A CN202210618445 A CN 202210618445A CN 114691343 A CN114691343 A CN 114691343A
Authority
CN
China
Prior art keywords
polling task
polling
execution
period
android system
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202210618445.0A
Other languages
Chinese (zh)
Other versions
CN114691343B (en
Inventor
钟晓锋
许锦洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Yishi Huolala Technology Co Ltd
Original Assignee
Shenzhen Yishi Huolala Technology Co Ltd
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 Shenzhen Yishi Huolala Technology Co Ltd filed Critical Shenzhen Yishi Huolala Technology Co Ltd
Priority to CN202210618445.0A priority Critical patent/CN114691343B/en
Publication of CN114691343A publication Critical patent/CN114691343A/en
Application granted granted Critical
Publication of CN114691343B publication Critical patent/CN114691343B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5021Priority
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a method for executing a polling task based on an android system. The execution method of the polling task comprises the following steps: a timer and a main thread manager with parallel periods as the first period, wherein the main thread manager is a main thread manager of the android system; judging whether a first execution interval is greater than or equal to a first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of a last polling task; and executing the polling task if the first execution interval is greater than or equal to the first period. The application also discloses a device for executing the polling task based on the android system, computer equipment and a computer-readable storage medium. Through parallel timer and main thread manager, utilize the tall and erect main thread priority of ann to guarantee that the message can regularly send out, the polling task is just in time carried out to timer and the two-way assurance of main thread, promotes user's use and experiences.

Description

Polling task execution method and device, computer equipment and readable storage medium
Technical Field
The present application relates to the field of task scheduling technologies, and in particular, to a method for executing a polling task based on an android system, an apparatus for executing a polling task based on an android system, a computer device, and a computer-readable storage medium.
Background
At present, on a mainstream App of an Android terminal, polling tasks are managed through manual registration and manual de-registration, and a Timer or a scheduled thread Pool execution is adopted to trigger detection and ensure the timed execution of the polling tasks. However, due to the scheduling of the system CPU, the use of the timer cannot guarantee that the polling task is executed on time, and the execution time error becomes larger and larger as time goes by, which reduces the user experience.
Disclosure of Invention
In order to solve at least one technical problem in the foregoing background, embodiments of the present application provide a method for executing a polling task based on an android system, an apparatus for executing a polling task based on an android system, a computer device, and a computer-readable storage medium.
The execution method of the polling task based on the android system comprises the following steps:
a timer and a main thread manager, wherein the parallel period of the timer and the main thread manager are the first period, and the main thread manager is the main thread manager of the android system;
judging whether a first execution interval is greater than or equal to the first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of the last execution of the polling task; and
and if the first execution interval is greater than or equal to the first period, executing the polling task.
In some embodiments, said performing said polling task comprises:
judging whether the number of the subtasks in the queue of the polling task is larger than zero or not;
if yes, circularly taking out the subtasks in the polling task, and judging whether the subtasks simultaneously meet the following conditions: the second period is greater than or equal to zero, and the second period is the execution period of the subtask; a second execution interval is greater than or equal to the second period, wherein the second execution interval is a current system timestamp and a timestamp of a last execution of the subtask; and the status of the subtask is valid; and
and if yes, starting the thread pool to execute the subtasks.
In some embodiments, before executing the polling task, the method for executing the polling task further includes:
and if the first execution interval is greater than or equal to the first period, recording the current system timestamp as the timestamp of executing the polling task this time.
In some embodiments, the method for performing a polling task further includes:
creating a lifecycle callback instance of the android system to monitor a lifecycle of a page; and
and when the life cycle callback example monitors that the page enters a terminal foreground to be visible, detecting the active state of the polling service, wherein the terminal is the running hardware environment of the android system.
In some embodiments, the method for performing a polling task further includes:
acquiring an alarm clock service example of the android system, and creating a timing broadcast with a third period; and
and awakening the process of the application every other third period, and detecting the active state of the polling service.
In some embodiments, the detecting an active state of the polling service comprises: judging whether the first execution interval is greater than or equal to a preset interval, wherein the preset interval is an integral multiple of the first period; if yes, judging that the polling service is in a stop state;
the execution method of the polling task further comprises the following steps: when the polling service is in a stop state, the timer and the main thread manager of which the parallel cycles are the same as the first cycle.
In some embodiments, the method for performing a polling task further includes:
creating a life cycle observer relying on a subtask of a page life cycle in the polling task; and
and when the fact that the page associated with the subtask exits is observed, the subtask is registered reversely.
The execution device of the polling task based on the android system in the embodiment of the application comprises:
the parallel module is used for a timer and a main thread manager, wherein the parallel cycle of the timer and the main thread manager is the same as the first cycle, and the main thread manager is the main thread manager of the android system;
the judging module is used for judging whether a first execution interval is greater than or equal to the first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of the last execution of the polling task; and
and the execution module is used for executing the polling task if the first execution interval is greater than or equal to the first period.
The computer device of the embodiment of the application comprises: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, the one or more computer programs configured to: the execution method of the android system-based polling task is implemented according to any embodiment of the application.
The non-transitory computer readable storage medium of the embodiments of the present application stores a computer program, and when the computer program is executed by one or more processors, the computer program causes the processors to execute the execution method of the android system based polling task described in any embodiment of the present application.
In the execution method of the polling task based on the android system, the execution device of the polling task based on the android system, the computer device and the computer readable storage medium in the embodiment of the application, the messages can be sent out at regular time by using the priority of the android main thread through the parallel timer and the main thread manager, the timer and the main thread can guarantee the on-time execution of the polling task in a two-way mode, and the use experience of a user is improved.
Additional aspects and advantages of embodiments of the present application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the present application.
Drawings
The above and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic flowchart of a method for executing a polling task based on an android system according to a first embodiment of the present application;
fig. 2 is a schematic flowchart of a method for executing a polling task based on an android system according to a second embodiment of the present application;
fig. 3 is a schematic flowchart of a method for executing a polling task based on an android system according to a third embodiment of the present application;
fig. 4 is a schematic flowchart of a method for executing a polling task based on an android system according to a fourth embodiment of the present application;
fig. 5 is a schematic flowchart of a method for executing a polling task based on the android system according to a fifth embodiment of the present application;
fig. 6 is a schematic block diagram of an apparatus for executing a polling task based on an android system according to a sixth embodiment of the present application;
fig. 7 is a schematic block diagram of an execution apparatus for a polling task based on an android system according to a seventh embodiment of the present application;
fig. 8 is a schematic block diagram of an execution apparatus for a polling task based on an android system according to an eighth embodiment of the present application;
fig. 9 is a schematic block diagram of an apparatus for executing a polling task based on an android system according to a ninth embodiment of the present application;
FIG. 10 is a schematic representation of a computer readable storage medium in communication with a processor according to some embodiments of the present application;
FIG. 11 is a schematic diagram of a computer device according to some embodiments of the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below by referring to the drawings are exemplary only for the purpose of explaining the embodiments of the present application, and are not to be construed as limiting the embodiments of the present application.
Referring to fig. 1, fig. 1 is a schematic flowchart of a method for executing a polling task based on an android system according to a first embodiment of the present application, where the method for executing a polling task based on an android system according to the embodiment of the present application includes:
01: a timer and a main thread manager with parallel periods as the first period, wherein the main thread manager is a main thread manager of the android system;
02: judging whether a first execution interval is greater than or equal to a first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of a last polling task; and
03: and if the first execution interval is larger than or equal to the first period, executing the polling task.
According to the execution method of the polling task based on the android system, the parallel timer and the main thread manager are adopted, the android main thread priority is used for ensuring that the message can be sent out at regular time, the timer and the main thread are used for ensuring that the polling task is executed on time, and the use experience of a user is improved.
Specifically, the Timer and the main thread manager Handler are the same as the first period, the main thread manager Handler ensures that the message can be sent out at regular time by using the Android main thread priority, and the error is in the millisecond level and within the single digit number. And when the first execution interval is judged to be greater than or equal to the first period, the polling task needs to be executed, so that the polling task is prevented from being executed in a delayed manner.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for executing a polling task based on an android system according to a second embodiment of the present application, where in some embodiments, the executing of the polling task in step 03 includes steps of:
031: judging whether the number of the subtasks in the queue of the polling task is greater than zero or not;
032: if yes, circularly taking out the subtasks in the polling task, and judging whether the subtasks simultaneously meet the following conditions: the second period is greater than or equal to zero, and the second period is the execution period of the subtask; the second execution interval is greater than or equal to a second period, and the second execution interval is a current system time stamp and a time stamp of the last execution of the subtask; and the status of the subtask is valid; and
033: and if yes, starting the thread pool to execute the subtasks.
Specifically, the polling task list may include a plurality of subtasks, and when the number of the subtasks is not greater than zero, that is, when there is no subtask in the polling task list, it is indicated that there is no polling task to be executed at this time, and step 01 may be continuously performed. And when the number of the subtasks is larger than zero, circularly taking out the subtasks in the polling task, meanwhile, starting to judge whether the taken-out subtasks need to be executed or not, and traversing other subtasks after judging whether the subtasks need to be executed or not.
When judging whether each subtask needs to be executed, judging whether the execution period (namely a second period) of the subtask is larger than zero, and simultaneously judging whether a second execution interval from the last execution of the ion task is larger than or equal to the second period, wherein the second period is a period set when the polling task is constructed, and simultaneously judging whether the state of the subtask is effective so as to ensure that the subtask is not subjected to back registration and the like.
Referring to fig. 3, fig. 3 is a flowchart illustrating a method for executing a polling task based on an android system according to a third embodiment of the present application, where in some embodiments, before executing the polling task, the method for executing the polling task further includes step 04: and if the first execution interval is greater than or equal to the first period, recording the current system timestamp as the timestamp of the current execution polling task.
Since the first execution interval is greater than or equal to the first period, meaning that the polling task is about to be executed, the first execution interval is ensured to be accurately calculated next time by recording the current system time stamp as the time stamp of the current execution of the polling task.
Referring to fig. 4, fig. 4 is a schematic flowchart of a method for executing a polling task based on an android system according to a fourth embodiment of the present application, where in some embodiments, the method for executing the polling task further includes:
05: establishing a life cycle callback example of the android system to monitor the life cycle of the page; and
06: and when the life cycle callback example monitors that the page enters the foreground of the terminal to be visible, detecting the active state of the polling service, wherein the terminal is the running hardware environment of the android system.
Specifically, a lifecycle callback instance ActivityLifecycleCallbacks of the android system is created, and when the fact that the page Activity enters a foreground of a terminal (such as a mobile phone, a tablet and the like) and is visible is monitored, the active state of the polling server is detected. And (3) monitoring by creating an ActivityLifecycleCallbacks, checking whether the polling task is normally executed according to a period when the page returns to the foreground, and immediately restarting and awakening the polling task if the polling task is not executed according to the period.
With continued reference to fig. 4, in some embodiments, the method for performing the polling task further includes the steps of:
07: acquiring an alarm clock service example of the android system, and establishing a timing broadcast with a third period; and
08: the application's process is woken up every third cycle and the polling service's active status is detected.
Specifically, an alarm clock service instance AlarmManager of the android system is obtained, a timing broadcast with a third period is established, an App process is awakened every other third period, the active state of the polling service is detected, the alarm clock service instance AlarmManager is utilized to awaken the system in the third period, the priority of the App program process is improved, the App process is guaranteed not to be cleared by the system, and therefore the sustainability of the polling task is guaranteed.
By implementing the steps 05, 06, 07 and 08, the alarm clock service instance AlarmManager and the Activity life cycle callback dual-capability keep-alive and the sustainability and stability of the execution of the wakeup polling task are utilized, so that the polling task has the keep-alive capability, the polling task is not executed because the App switches to the background or the terminal sleeps, the influence of the system CPU scheduling is avoided, the polling task can be executed periodically on time, the polling task has the keep-alive and restart correction capabilities, and the polling task can be reached at regular time during the use period of the App.
Continuing to refer to fig. 4, in some embodiments, detecting an active state of the polling service includes the steps of:
09: judging whether the first execution interval is greater than or equal to a preset interval, wherein the preset interval is an integral multiple of the first period; and
0 a: if yes, judging that the polling service is in a stop state;
the execution method of the polling task further comprises the following steps: when the polling service is in a stop state, step 01 is implemented: the parallel cycle is the timer and the main thread manager of the first cycle.
Specifically, as mentioned above, the first execution interval (i.e. interval) is calculated as follows: current system timestamp-last time timestamp is executed, if interval > = Z × N (Z is a positive integer, not limited to 2, N is the first period), the polling service is considered to be dead (i.e. stop), and needs to be reset, and then the execution method of the polling task is executed from step 01 again.
Referring to fig. 5, fig. 5 is a schematic flowchart of a method for executing a polling task based on an android system according to a fifth embodiment of the present application, where in some embodiments, the method for executing the polling task further includes:
0 b: creating a polling task, relying on a life cycle observer of a subtask of a page life cycle; and
0 c: and when the page exit associated with the subtask is observed, the subtask is reversely registered.
Specifically, when a business side creates a polling task and registers the polling task into a polling service, a host Lifecycle object of Activity or Fragment is transmitted, for a subtask depending on a page life cycle, a Lifecycle observer is created, and when a page callback event onDestroy occurs in the observed person page Activity, a counterregistration method unregisterpoltatsk is manually called to remove a subtask instance, so that the capacity of automatically recycling the polling task is achieved. Therefore, the polling task based on the page level can automatically recover the polling task along with the exit of the page, the memory leakage of the App program caused by forgetting to reverse-register the polling task can be avoided, and a user can conveniently concentrate on the creation and implementation of the polling task without paying attention to the management of the polling task.
Referring to fig. 6, fig. 6 is a schematic block diagram of a polling task execution device 10 based on the android system according to a sixth embodiment of the present application, where the polling task execution device 10 includes a parallel module 11, a determination module 12, and an execution module 13. The parallel module 11 may be configured to implement step 01, that is, the parallel module 11 may be configured to use a timer and a main thread manager whose parallel cycles are the same as the first cycle, where the main thread manager is a main thread manager of the android system. The determining module 12 may be configured to implement step 02, that is, the determining module 12 may be configured to determine whether a first execution interval is greater than or equal to a first period, where the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of a last polling task executed. The execution module 13 may be configured to perform step 03, that is, the execution module 13 may be configured to execute the polling task if the first execution interval is greater than or equal to the first period.
With continued reference to fig. 6, in some embodiments, the execution module 13 may be configured to perform steps 031, 032 and 033, that is, the execution module 13 may be configured to: judging whether the number of the subtasks in the queue of the polling task is greater than zero or not; if yes, circularly taking out the subtasks in the polling task, and judging whether the subtasks simultaneously meet the following conditions: the second period is greater than or equal to zero, and the second period is the execution period of the subtask; the second execution interval is greater than or equal to a second period, and the second execution interval is a current system time stamp and a time stamp of the last execution of the subtask; and the status of the subtask is valid; and if yes, starting the thread pool to execute the subtasks.
Referring to fig. 7, fig. 7 is a schematic block diagram of an execution device 10 for a polling task based on an android system according to a seventh embodiment of the present application, in some embodiments, the execution device 10 for a polling task further includes a recording module 14, and the recording module 14 may be configured to perform step 04, that is, if the first execution interval is greater than or equal to the first period, the recording module 14 may be configured to record a current system timestamp as a timestamp of the current polling task.
Referring to fig. 8, fig. 8 is a schematic block diagram of an execution device 10 for a polling task based on an android system according to an eighth embodiment of the present application, where in some embodiments, the execution device 10 for a polling task further includes a monitoring module 15 and a detection module 17. Listening module 15 may be configured to implement step 05, that is, listening module 15 may be configured to create a lifecycle callback instance of the android system to listen to a lifecycle of the page. The detection module 17 may be configured to perform step 06, that is, the detection module 17 may be configured to detect an active state of the polling service when the lifecycle callback instance monitors that the page enters into the foreground of the terminal to be visible.
Referring to fig. 8, in some embodiments, the device 10 for executing the polling task further includes a broadcasting module 16 and a detecting module 17. Broadcast module 16 may be configured to implement step 07, that is, broadcast module 16 may be configured to obtain an alarm service instance of the android system, and create a timing broadcast with a period of a third period. The detection module 17 may be configured to implement step 08, i.e. the detection module 17 may be configured to wake up the process of the application every third cycle and detect the active status of the polling service.
Referring to fig. 8, in some embodiments, the detecting module 17 may be configured to perform step 09 and step 0a, that is, the detecting module 17 may be configured to determine whether the first execution interval is greater than or equal to a predetermined interval, where the predetermined interval is an integer multiple of the first period; and if so, judging that the polling service is in a stop state. The parallel module 11 may be used for a timer and a main thread manager, which have a parallel cycle being the same as the first cycle when the polling service is in a stop state.
Referring to fig. 9, fig. 9 is a schematic block diagram of a polling task execution device 10 based on the android system according to a ninth embodiment of the present application, and in some embodiments, the polling task execution device 10 further includes an observation module 18 and an anti-registration module 19. The observation module 18 may be used to implement step 0b, i.e., the observation module 18 may be used to create a life-cycle observer of a subtask that relies on the life cycle of the page in a polling task. The de-registration module 19 may be configured to perform step 0c, i.e. the de-registration module 19 may be configured to de-register the subtask upon observing exit of the page associated with the subtask.
It should be noted that, the details of the implementation and the effects achieved when the polling task execution device 10 implements the polling task execution method according to any embodiment of the present application may refer to the above description of the polling task execution method, and are not described herein again.
In addition, referring to fig. 10, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for executing the polling task according to any one of the above embodiments. The computer-readable storage medium includes, but is not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magnetic-optical disks, ROMs (Read-Only memories), RAMs (Random Access memories), EPROMs (Erasable Programmable Read-Only memories), EEPROMs (Electrically Erasable Programmable Read-Only memories), flash memories, magnetic cards, or optical cards. That is, a storage device includes any medium that stores or transmits information in a form readable by a device (e.g., a computer, a cellular phone), and may be a read-only memory, a magnetic or optical disk, or the like.
The contents of the method embodiments of the present application are all applicable to the storage medium embodiments, the functions specifically implemented by the storage medium embodiments are the same as those of the method embodiments, and the beneficial effects achieved by the storage medium embodiments are also the same as those achieved by the method described above, and for details, refer to the description of the method embodiments, and are not described herein again.
In addition, referring to fig. 11, an embodiment of the present application further provides a computer device, where the computer device described in this embodiment may be a server, a personal computer, a network device, and other devices. The computer device includes one or more processors, memory, and one or more computer programs. Wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors. One or more computer programs are configured to perform the method of performing a polling task described in any of the above embodiments.
In the description herein, reference to the description of the terms "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example" or "some examples" or the like means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Moreover, various embodiments or examples and features of various embodiments or examples described in this specification can be combined and combined by one skilled in the art without being mutually inconsistent.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps in the process, and alternate implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
Although embodiments of the present application have been shown and described above, it is to be understood that the above embodiments are exemplary and not to be construed as limiting the present application, and that changes, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.

Claims (10)

1. A polling task execution method based on an android system is characterized by comprising the following steps:
a timer and a main thread manager, wherein the parallel period of the timer and the main thread manager are the first period, and the main thread manager is the main thread manager of the android system;
judging whether a first execution interval is greater than or equal to the first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of the last execution of the polling task; and
and if the first execution interval is greater than or equal to the first period, executing the polling task.
2. The method of performing a polling task according to claim 1, wherein said performing the polling task comprises:
judging whether the number of the subtasks in the queue of the polling task is larger than zero or not;
if yes, circularly taking out the subtasks in the polling task, and judging whether the subtasks simultaneously meet the following conditions: the second period is greater than or equal to zero, and the second period is the execution period of the subtask; a second execution interval is greater than or equal to the second period, wherein the second execution interval is a current system timestamp and a timestamp of a last execution of the subtask; and the status of the subtask is valid; and
and if yes, starting the thread pool to execute the subtasks.
3. The method of performing a polling task according to claim 1, wherein prior to performing the polling task, the method of performing a polling task further comprises:
and if the first execution interval is greater than or equal to the first period, recording the current system timestamp as the timestamp of executing the polling task this time.
4. The method of performing a polling task according to claim 1, further comprising:
creating a lifecycle callback instance of the android system to monitor a lifecycle of a page; and
and when the life cycle callback example monitors that the page enters a terminal foreground to be visible, detecting the active state of the polling service, wherein the terminal is the running hardware environment of the android system.
5. The method of performing a polling task according to claim 4, further comprising:
acquiring an alarm clock service example of the android system, and creating a timing broadcast with a third period; and
and awakening the process of the application every other third period, and detecting the active state of the polling service.
6. The method of claim 5, wherein detecting the active status of the polling service comprises: judging whether the first execution interval is greater than or equal to a preset interval, wherein the preset interval is an integral multiple of the first period; if yes, judging that the polling service is in a stop state;
the execution method of the polling task further comprises the following steps: when the polling service is in a stop state, the timer and the main thread manager of which the parallel cycles are the same as the first cycle.
7. The method for performing polling tasks of claim 1, wherein the method for performing polling tasks further comprises:
creating a life cycle observer relying on a subtask of a page life cycle in the polling task; and
and when the fact that the page associated with the subtask exits is observed, the subtask is registered reversely.
8. An execution device of a polling task based on an android system is characterized in that the execution device of the polling task comprises:
the parallel module is used for a timer and a main thread manager, wherein the parallel cycle of the timer and the main thread manager is the same as the first cycle, and the main thread manager is the main thread manager of the android system;
the judging module is used for judging whether a first execution interval is greater than or equal to the first period, wherein the first execution interval is a time interval between a current system timestamp of the android system and a timestamp of the last execution of the polling task; and
and the execution module is used for executing the polling task if the first execution interval is greater than or equal to the first period.
9. A computer device, comprising:
one or more processors;
a memory; and
one or more computer programs, wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, the one or more computer programs configured to: a method of performing a polling task according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by one or more processors, causes the processors to perform the method of performing a polling task of any one of claims 1 to 7.
CN202210618445.0A 2022-06-02 2022-06-02 Polling task execution method and device, computer equipment and readable storage medium Active CN114691343B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210618445.0A CN114691343B (en) 2022-06-02 2022-06-02 Polling task execution method and device, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210618445.0A CN114691343B (en) 2022-06-02 2022-06-02 Polling task execution method and device, computer equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN114691343A true CN114691343A (en) 2022-07-01
CN114691343B CN114691343B (en) 2022-08-26

Family

ID=82131280

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210618445.0A Active CN114691343B (en) 2022-06-02 2022-06-02 Polling task execution method and device, computer equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114691343B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07200311A (en) * 1994-01-07 1995-08-04 Fuji Facom Corp Interval processor for computer system
CN105630492A (en) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 Method and device for packaging periodic task of application
CN106775620A (en) * 2016-11-14 2017-05-31 武汉斗鱼网络科技有限公司 A kind of timing method and device
CN109445954A (en) * 2018-09-11 2019-03-08 百富计算机技术(深圳)有限公司 A kind of execution method, terminal device and the storage medium of timed task
CN112651040A (en) * 2020-12-15 2021-04-13 中国银联股份有限公司 Permission application method, component, device and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07200311A (en) * 1994-01-07 1995-08-04 Fuji Facom Corp Interval processor for computer system
CN105630492A (en) * 2015-12-21 2016-06-01 北京奇虎科技有限公司 Method and device for packaging periodic task of application
CN106775620A (en) * 2016-11-14 2017-05-31 武汉斗鱼网络科技有限公司 A kind of timing method and device
CN109445954A (en) * 2018-09-11 2019-03-08 百富计算机技术(深圳)有限公司 A kind of execution method, terminal device and the storage medium of timed task
CN112651040A (en) * 2020-12-15 2021-04-13 中国银联股份有限公司 Permission application method, component, device and computer readable storage medium

Also Published As

Publication number Publication date
CN114691343B (en) 2022-08-26

Similar Documents

Publication Publication Date Title
EP2977854B1 (en) Method, apparatus, and user terminal for removing malicious power consuming application
US8166145B2 (en) Managing event-based conditional recurrent schedules
US10075409B2 (en) Terminal and application synchronization method therefor
CN102200942A (en) Cloud-computing-based application program behavior monitoring method and cloud server
CN110109741B (en) Method and device for managing circular tasks, electronic equipment and storage medium
WO2017219834A1 (en) Monitoring method and device, and watchdog system
EP3671461A1 (en) Systems and methods of monitoring software application processes
CN111796954A (en) Watchdog control method, device, equipment and storage medium based on JVM
CN107436672B (en) Application processing method and terminal
US20170160778A1 (en) Method and device for monitoring power-consuming applications, user terminal, computer program and storage medium
CN112817772B (en) Data communication method, device, equipment and storage medium
CN111625322B (en) Data processing method, system and equipment
CN106775620B (en) Timing method and device
WO2022095862A1 (en) Thread priority adjusting method, terminal, and computer readable storage medium
CN114691343B (en) Polling task execution method and device, computer equipment and readable storage medium
CN110688206A (en) Timing task scheduling method and device, computer equipment and storage medium
CN111078441A (en) System running state monitoring method and device and electronic equipment
CN113535344A (en) Network data processing method and device, server and storage medium
CN110402574B (en) Method for operating a device during a period of unavailability
US8607232B2 (en) Identifying a transient thread and excluding the transient thread from a processor load calculation
EP3929737A1 (en) Application state control method apparatus, and terminal and computer-readable storage medium
CN114780296A (en) Data backup method, device and system for database cluster
EP3916549A1 (en) Broadcast control method, terminal and computer readable storage medium
CN111796949A (en) Communication task processing method, device, equipment and storage medium
CN112463348A (en) Timed task processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant