Timing method and device, resource distribution system, computer device and storage medium

By adjusting the timing results in response to changes in rendering state on the terminal device, the problem of inaccurate timing during background operation on the terminal device is solved, achieving more accurate and reliable timing.

CN115357364BActive Publication Date: 2026-05-29BEIJING ZITIAO NETWORK TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2022-09-01
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In existing technologies, the problem of inaccurate timing arises because terminal devices continue to send heartbeat packets to the server while running in the background.

Method used

The timing result is determined by responding to rendering state change information in the terminal device. Multiple timing cycles are used, and the current target timing duration is determined by using the preset timing length or the timing result of the previous timing cycle. The timing result is adjusted based on the rendering state change information.

Benefits of technology

It improves the accuracy and reliability of timing, enabling accurate calculation of the actual rendering time of the application when the rendering environment is complex and changing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115357364B_ABST
    Figure CN115357364B_ABST
Patent Text Reader

Abstract

The present disclosure provides a timing method, device, resource distribution system, computer device and storage medium. The method comprises: in response to a triggered timing event, in each timing period, performing the following process: determining a current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a pre-designed timing duration or a timing result of a previous timing period corresponding to the current timing period; timing based on the current target timing duration; in response to the timing reaching the current target timing duration, determining rendering state change information of the terminal device in the current timing period, and determining a timing result of the current timing period based on the rendering state change information, and entering a next timing period.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer application technology, and more specifically, to a timing method, apparatus, resource distribution system, computer equipment, and storage medium. Background Technology

[0002] In application development, there is often a need for terminal devices to report timing, such as timing the rendering time of a page in an application on the terminal device. Current terminal devices typically use a persistent connection to continuously send heartbeat packets to achieve this timing. However, in this implementation, even if the application on the terminal device is running in the background and the user is not actively using the application, the terminal device will still continuously send heartbeat packets to the server. As long as the server receives a heartbeat packet from the terminal device, it will continue timing, leading to inaccurate timing results in the current method. Summary of the Invention

[0003] This disclosure provides at least one timing method, apparatus, resource distribution system, computer device, and storage medium.

[0004] In a first aspect, embodiments of this disclosure provide a timing method applied to a terminal device;

[0005] In response to a triggered timing event, the following procedure is performed in each of the multiple timing cycles:

[0006] Determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period;

[0007] Timing is performed based on the current target duration.

[0008] In response to the timing reaching the current target timing duration, the rendering state change information of the terminal device in the current timing cycle is determined, and based on the rendering state change information, the timing result of the current timing cycle is determined, and the next timing cycle is entered.

[0009] In one optional implementation, in response to the current timing period being the first timing period, determining the current target timing duration corresponding to the current timing period includes:

[0010] Receive the preset timing duration sent by the target application, and determine the preset timing duration as the current target timing duration;

[0011] In response to the fact that the current timing period is not the first counting period, determining the current target timing duration corresponding to the current timing period includes:

[0012] The current target timing duration is determined based on the timing result of the previous timing cycle and the target timing duration of the previous timing cycle.

[0013] In one optional implementation, determining the current target timing duration based on the timing result of the previous timing period and the target timing duration of the previous timing period includes:

[0014] Determine whether the actual timing duration indicated by the timing result corresponding to the previous timing cycle is equal to the target timing duration of the previous timing cycle;

[0015] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is the same as the target timing duration of the previous timing period, the preset timing duration is determined as the current target timing duration;

[0016] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is less than the target timing duration of the previous timing period, the difference between the target timing duration of the previous timing period and the actual timing duration indicated by the timing result corresponding to the previous timing period is determined as the current target timing duration.

[0017] In one optional implementation, the step of timing based on the current target duration includes:

[0018] Based on the current target time duration, a timing instruction corresponding to the current target time duration is generated; the timing instruction is sent to the timing component so that the timing component performs timing based on the current target time duration carried in the timing instruction.

[0019] In an optional implementation, the method further includes: generating a delay message corresponding to the current target timing duration, and storing the delay message in a preset storage space; the delay message carries a first timestamp indicating the start of timing corresponding to the current timing period;

[0020] In response to the timing reaching the current target timing duration, the system determines the rendering state change information of the terminal device in the current timing period, and determines the timing result of the current timing period based on the rendering state change information, including:

[0021] In response to receiving the timing end signal sent by the timing component, the delay message is read from the preset storage space, and the timing result of the current timing period is determined based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message.

[0022] In one optional implementation, determining the timing result of the current timing period based on the first timestamp of the start of timing corresponding to the current timing period, the current target timing duration, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message includes:

[0023] In response to the absence of rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period and the second timestamp of the current time.

[0024] In response to obtaining rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device.

[0025] In one optional implementation, the rendering state change information includes: a third timestamp when the rendering state changes, and the rendering state corresponding to the third timestamp.

[0026] In one optional implementation, the step of responding to obtaining rendering state change information indicating a change in the rendering state of the terminal device during the current timing period, and determining the timing result based on a first timestamp of the start of timing corresponding to the current timing period, a second timestamp of the current time, and the rendering state change information of the terminal device, includes:

[0027] Based on the rendering status corresponding to the third timestamp, as well as the first timestamp and the second timestamp, the target time period for the terminal device to render the target page is determined;

[0028] Based on the start and end times of the target time period, the rendering duration corresponding to the target time period is determined;

[0029] The timing result is determined based on the rendering duration corresponding to the target time period.

[0030] In one optional implementation, the timing result includes: the actual timing duration corresponding to the current timing period;

[0031] The method further includes:

[0032] Based on the actual timing duration corresponding to the current timing cycle and the cumulative timing duration corresponding to the previous timing cycle, the cumulative timing duration corresponding to the current timing cycle is determined.

[0033] In response to the cumulative time duration corresponding to the current time period reaching a preset time duration, a time request is sent to the server. The time request carries the cumulative time duration corresponding to the current time period. The time request is used to instruct the server to issue reward resources to the terminal device after determining that the total time duration corresponding to multiple time periods has reached the target time duration based on the cumulative time duration corresponding to the current time period. The preset time duration is determined based on the target time duration required by the server to issue the reward resources.

[0034] In one optional implementation, the method further includes:

[0035] In response to receiving a timer stop command from the server, the timer is stopped.

[0036] Secondly, embodiments of this disclosure also provide a timing device applied to a terminal device.

[0037] In response to a trigger timing event, the timing device performs the following process in each of a plurality of timing cycles:

[0038] The first determining module is used to determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period;

[0039] The timing module is used to perform timing based on the current target timing duration;

[0040] The second determining module is used to determine the rendering state change information of the terminal device in the current timing cycle in response to the timing reaching the current target timing duration, and to determine the timing result of the current timing cycle based on the rendering state change information, and to enter the next timing cycle.

[0041] In an optional implementation, when the first determining module responds to the current timing period being the first timing period and determines the current target timing duration corresponding to the current timing period, it is used to:

[0042] Receive the preset timing duration sent by the target application, and determine the preset timing duration as the current target timing duration;

[0043] When the first determining module determines the current target timing duration corresponding to the current timing period in response to the current timing period not being the first counting period, it is used to:

[0044] The current target timing duration is determined based on the timing result of the previous timing cycle and the target timing duration of the previous timing cycle.

[0045] In an optional implementation, when the first determining module determines the current target timing duration based on the timing result of the previous timing period and the target timing duration of the previous timing period, it is further configured to:

[0046] Determine whether the actual timing duration indicated by the timing result corresponding to the previous timing cycle is equal to the target timing duration of the previous timing cycle;

[0047] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is the same as the target timing duration of the previous timing period, the preset timing duration is determined as the current target timing duration;

[0048] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is less than the target timing duration of the previous timing period, the difference between the target timing duration of the previous timing period and the actual timing duration indicated by the timing result corresponding to the previous timing period is determined as the current target timing duration.

[0049] In an optional implementation, when the timing module is timing based on the current target duration, it is used to:

[0050] Based on the current target time duration, a timing instruction corresponding to the current target time duration is generated; the timing instruction is sent to the timing component so that the timing component performs timing based on the current target time duration carried in the timing instruction.

[0051] In one optional implementation, the timing device further includes a message generation module, used for:

[0052] Generate a delay message corresponding to the current target timing duration, and store the delay message in a preset storage space; the delay message carries a first timestamp of the start of timing corresponding to the current timing period;

[0053] When the second determining module determines the rendering state change information of the terminal device in the current timing period in response to the timing reaching the current target timing duration, and determines the timing result of the current timing period based on the rendering state change information, it is used to:

[0054] In response to receiving the timing end signal sent by the timing component, the delay message is read from the preset storage space, and the timing result of the current timing period is determined based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message.

[0055] In an optional implementation, the second determining module, when determining the timing result of the current timing period based on the first timestamp of the start of timing corresponding to the current timing period, the current target timing duration, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message, is further configured to:

[0056] In response to the absence of rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period and the second timestamp of the current time.

[0057] In response to obtaining rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device.

[0058] In an optional implementation, the second determining module, when determining the timing result based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device obtained in the current timing period, is further configured to:

[0059] Based on the rendering status corresponding to the third timestamp, as well as the first timestamp and the second timestamp, the target time period for the terminal device to render the target page is determined;

[0060] Based on the start and end times of the target time period, the rendering duration corresponding to the target time period is determined;

[0061] The timing result is determined based on the rendering duration corresponding to the target time period.

[0062] In an optional embodiment, the device further includes a sending module, which, when determining the cumulative timing duration corresponding to the current timing period based on the actual timing duration corresponding to the current timing period and the cumulative timing duration corresponding to the previous timing period, is used to:

[0063] In response to the cumulative time duration corresponding to the current time period reaching a preset time duration, a time request is sent to the server. The time request carries the cumulative time duration corresponding to the current time period. The time request is used to instruct the server to issue reward resources to the terminal device after determining that the total time duration corresponding to multiple time periods has reached the target time duration based on the cumulative time duration corresponding to the current time period. The preset time duration is determined based on the target time duration required by the server to issue the reward resources.

[0064] In one optional implementation, the apparatus further includes a receiving module for:

[0065] In response to receiving a timer stop command from the server, the timer is stopped.

[0066] Thirdly, embodiments of this disclosure provide a resource allocation system, including: a terminal device and a server; the terminal device includes a first thread and a second thread;

[0067] The terminal device is configured to perform the following process in each of a plurality of timing cycles:

[0068] The first thread, in response to receiving the timing duration of the current timing period, generates a delay message and a timing instruction corresponding to the timing duration, sends the delay message to the delay message queue, and sends the timing instruction to the timing component; the second thread, in response to receiving a timing end signal from the timing component based on the timing duration, reads the delay message from the delay message queue, and determines the current cumulative timing duration based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device; in response to the current cumulative timing duration reaching a preset duration threshold, sends a timing request to the server.

[0069] Fourthly, an optional implementation of this disclosure also provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is configured to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the steps of the first aspect above, or any possible implementation of the first aspect, are performed.

[0070] Fifthly, an optional implementation of this disclosure also provides a computer-readable storage medium storing a computer program that, when rendered, executes the steps of the first aspect or any possible implementation of the first aspect.

[0071] The timing method provided in this disclosure, in response to a triggered timing event, determines the current target timing duration corresponding to the current timing period, and performs timing based on the current target timing duration. Upon reaching the target timing duration, it determines rendering state change information, which characterizes whether the rendering state of the terminal device has changed in the current timing period, and determines the timing result of the current timing period based on the rendering state change information. Thus, since the timing result of the current timing period is determined based on the rendering state change information of the terminal device, it can more accurately measure the actual rendering duration of the application, improving timing accuracy.

[0072] In addition, in this embodiment, the current target timing duration corresponding to each timing cycle is determined based on the timing result of the previous timing cycle or the preset timing duration. Therefore, it can adapt to the complex changes in the rendering environment of the terminal device, achieve accurate timing, and improve the reliability of timing.

[0073] For a description of the effects of the aforementioned timing device, resource distribution system, computer equipment, and computer-readable storage medium, please refer to the description of the timing method above; it will not be repeated here.

[0074] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0075] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0076] Figure 1 A flowchart of a timing method provided by an embodiment of this disclosure is shown;

[0077] Figure 2 The flowchart illustrates a specific method for determining the timing result based on rendering state change information in the timing method provided in this embodiment of the present disclosure.

[0078] Figure 3 A schematic diagram illustrating the specific method for calculating the actual timing duration in the timing method provided in the embodiments of this disclosure is shown;

[0079] Figure 4This illustration shows a specific example of a timing method provided in the embodiments of this disclosure;

[0080] Figure 5 This illustration shows a specific example of another timing method provided in the embodiments of this disclosure;

[0081] Figure 6 A schematic diagram of a resource allocation system provided in an embodiment of this disclosure is shown;

[0082] Figure 7 A schematic diagram of a timing device provided in an embodiment of this disclosure is shown;

[0083] Figure 8 A schematic diagram of a computer device provided in an embodiment of this disclosure is shown. Detailed Implementation

[0084] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown herein can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0085] Research has revealed the need for timing in many application scenarios on terminal devices. For example, in the case of a game application, after a user's character successfully logs in and remains logged in for a certain period, game resources are distributed to the character. In this case, the duration of the character's login time needs to be timed. Similarly, in other applications, under certain conditions, the application may redirect to a specific page; after this page is rendered and displayed for a certain period, resources or rewards are distributed to the user. In this case, the rendering time of this specific page on the terminal device needs to be timed. Current timing methods typically involve the terminal device periodically sending heartbeat packets to the server, and the server timing based on the time period corresponding to the received heartbeat packets. However, in this implementation, even if the application switches from foreground rendering to background operation, the terminal device will still send heartbeat packets to the server while running in the background, and the server will still receive these heartbeat packets and use them for timing. In reality, the time the application spends running in the background does not need to be included in the timing, therefore, the current timing method suffers from inaccurate timing.

[0086] Based on the above research, this disclosure provides a timing method, apparatus, resource allocation system, computer storage device, and storage medium, which are applied to terminal devices. The terminal device determines the timing result of the current timing cycle based on its rendering state change information. Different timing results are determined depending on whether the rendering state of the terminal device changes. Therefore, it is possible to more accurately count the actual rendering duration of the application and improve the accuracy of timing.

[0087] In addition, in this embodiment, the current target timing duration corresponding to each timing cycle is determined based on the timing result of the previous timing cycle or the preset timing duration. Therefore, it can adapt to the complex changes in the rendering environment of the terminal device, achieve accurate timing, and improve the reliability of timing.

[0088] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.

[0089] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0090] To facilitate understanding of this embodiment, a timing method disclosed in this disclosure will first be described in detail. The execution subject of the timing method provided in this disclosure is generally a computer device with certain computing capabilities. This computer device may include, for example, a terminal device or other processing device. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, this timing method can be implemented by a processor calling computer-readable instructions stored in memory.

[0091] The timing method provided in this disclosure can be applied to various applications deployed in a terminal device. In response to a triggered timing event, it times the rendering duration of a specific page rendered in the application. This application can be of various types, such as games, shopping apps, financial services, etc., and this disclosure does not limit its scope.

[0092] The timing method provided in this disclosure can be applied to terminal devices. In one possible implementation, a target application carrying the timing method of this application is deployed in the terminal device. After the target application is started, the terminal device creates a main thread for running the target application. The main thread can execute the timing method provided in this disclosure in response to a timing event being triggered.

[0093] Among them, the timing events include the opening of a preset target page, such as the target page that needs to be opened when a virtual character in a game is resurrected after being killed, the target page that opens when the application starts, the target page during video playback, etc. The specific settings are based on the actual application scenario and are not limited here.

[0094] For example, in a game program, when a virtual character dies in the game, a revive button is displayed in a pop-up interface. When the user clicks the revive button, they are redirected to a target page. The user needs to stay on the target page for a certain period of time. After the period expires, the virtual character can be given a chance to revive. In this case, the redirection to the target page can be treated as an operation on a timed event.

[0095] For example, if, after the application starts, a target page that the application displays to the user will give the user a certain reward after being displayed for a certain period of time, then the operation of opening the target page can be used as the trigger for the timed event.

[0096] For example, the rendered page content and timer can be displayed on the target page. If the user exits the target page during the timer, the timer stops. When the user re-enters the target page, the timer resumes until the timer expires and the reward is issued. The user can also exit the target page early. If the user exits the target page early, the corresponding reward will not be issued.

[0097] In addition, some embodiments of this disclosure also involve a first thread, a second thread, and a delayed message queue, wherein:

[0098] The first thread and the second thread are used to execute certain steps in the timing process, and the timing work is completed through the mutual cooperation between the first thread, the second thread, and the main thread of the target application.

[0099] The first and second threads can be created when timing is required and destroyed after timing is complete. Alternatively, the first and second threads can be created after the application that requires timing starts running on the terminal device, and execute the timing logic when timing is needed, stopping the timing logic when timing is no longer required; they are destroyed when the application is closed.

[0100] In each timing cycle of the specific timing process, at the start of timing, the first thread generates a delayed message and stores it in a delayed message queue. As the timing cycle ends, the delayed messages in the queue are read by the second thread and then cleared, until the delayed message for the next timing cycle is received from the first thread. Therefore, whenever a new delayed message is received, the existing delayed messages in the queue are cleared, ensuring that there are no conflicts or timing errors when retrieving delayed messages.

[0101] In addition, after the delayed messages stored in the delayed message queue are read by the second thread, the second thread determines the timing result of each timing cycle based on the rendering state change information of each timing cycle.

[0102] The specific working process of the first thread, the second thread, and the delayed message queue mentioned above will be described in detail below.

[0103] In this embodiment of the disclosure, each timing cycle corresponds to a target timing duration, which is used to indicate the duration that a timing cycle needs to be timed.

[0104] The timing method provided in the embodiments of this disclosure will be described below.

[0105] See Figure 1The flowchart shown is a timing method provided in an embodiment of this disclosure. In response to triggering a target event, in each of a plurality of timing cycles, at least the following steps S101 to S103 are performed:

[0106] S101: Determine the current target timing duration corresponding to the current timing cycle; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing cycle corresponding to the current timing cycle.

[0107] In specific embodiments, the current target timing duration for different timing cycles may be the same or different, depending on the preset timing duration or the timing result of the previous timing cycle corresponding to the current timing cycle.

[0108] When determining the current target timing duration for the current timing period, at least one of the following A1 to A2 may be included, but is not limited to:

[0109] A1. The current timing period is the first timing period. The preset timing duration sent by the target application is received, and the preset timing duration is determined as the current target timing duration.

[0110] The preset timing duration is a fixed value set according to actual needs. It is also the maximum duration of the current timing determined in at least one timing cycle included in a complete timing event. Its specific value is not specifically limited here.

[0111] For example, the preset timing duration sent by the target application can be pre-set by the program developers and stored in a fixed storage space; when a timing event is triggered, before executing the first timing cycle, the main thread of the target application creates a first thread and sends the preset timing duration of the target application to the first thread. In response to receiving the preset timing duration sent by the main thread, the first thread starts executing the first timing cycle, generates a timing instruction and a delay message according to the preset timing duration, sends the timing instruction to the timing component, and stores the delay message in the delay message queue.

[0112] A2. The current timing period is not the first timing period. Based on the timing result of the previous timing period and the target timing duration of the previous timing period, the current target timing duration is determined.

[0113] Here, since the current timing period is not the first timing period, that is, when the current timing period is the i-th (i>1) timing period, the timing result corresponding to the i-1 timing period has actually been obtained. The timing result indicates the actual timing duration of the i-1 timing period.

[0114] During the (i-1)th timing cycle, there may be two cases: M1 and M2.

[0115] M1: In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is the same as the target timing duration of the previous timing period, the preset timing duration is determined as the current target timing duration.

[0116] In other words, during the (i-1)th timing cycle, the target page was not switched out (i.e., the target page was switched from foreground to background display). Therefore, the actual timing duration of the (i-1)th timing cycle is equal to the target timing duration of the (i-1)th timing cycle. At this point, the preset timing duration can be set as the current target timing duration corresponding to the i-th timing cycle.

[0117] For example, if the actual timing duration indicated by the timing result is equal to the target timing duration when the target application is executing a non-first timing cycle, it means that the target application has fully executed the target timing duration in the previous timing cycle. That is, no rendering changes occurred when the target application executed the previous timing cycle. Based on the above situation, the target application determines the current timing cycle as the new timing cycle. The second thread or the main thread sends the preset timing duration to the first thread. The first thread generates timing instructions and delay messages based on the preset timing duration for subsequent actions.

[0118] M2: In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is less than the target timing duration of the previous timing period, the difference between the target timing duration of the previous timing period and the actual timing duration indicated by the timing result corresponding to the previous timing period is determined as the current target timing duration.

[0119] In other words, during the (i-1)th timing cycle, the target page was switched out, so the actual timing duration T1 of the previous timing cycle could not reach the target timing duration T2 of the previous timing cycle. Therefore, in the current timing cycle, if we want to make up for the timing difference (T2-T1) between the target timing duration and the actual timing duration in the (i-1)th timing cycle, we can use this timing difference (T2-T1) as the current target timing duration corresponding to the current i-th timing cycle.

[0120] For example, if the actual timing duration indicated by the timing result in the (i-1)th timing cycle is less than the target timing duration when the target application is executing a non-first timing cycle, it means that the target application did not fully execute the target timing duration in the previous timing cycle. In other words, the rendering state information changed during the execution of the previous timing cycle. Based on this, the target application determines that the current timing cycle needs to continue executing the remaining timing duration from the previous timing cycle. Then, the second thread or the main thread subtracts the actual timing duration indicated by the timing result from the previous timing cycle's target timing duration to obtain the current target timing duration for the current timing cycle. The first thread generates timing instructions and delay messages based on the current target timing duration for subsequent actions.

[0121] Following the above S101, the timing method provided in this embodiment further includes:

[0122] S102, start timing based on the current target timing duration.

[0123] In one embodiment of this disclosure, a specific method for timing based on a current target duration is provided, including: generating a timing instruction corresponding to the current target duration based on the current target duration; and sending the timing instruction to a timing component so that the timing component performs timing based on the current target duration carried in the timing instruction.

[0124] Among them, the timing component can be, for example, a timing component provided by the operating system of the terminal device, which can provide an interface for various applications of the terminal device to call; when each application has a timing requirement, it can call the corresponding timing component through the interface to perform timing.

[0125] For example, the first thread generates a timing command in each timing cycle and sends the timing command to the timing component. In response to receiving the timing command from the first thread, the timing component starts timing based on the current target timing duration of the current timing cycle carried in the timing command, and sends the timing end signal to the second thread after the timing ends. For instance, if the current target timing duration of the current timing cycle carried in the timing command is 10 seconds, the timing component starts timing after receiving the timing command; when the timing duration reaches 10 seconds, it sends a timing end signal to the second thread to indicate that the timing for the current timing command has ended.

[0126] Following the above S102, the timing method provided in this embodiment further includes:

[0127] S103, in response to the timing reaching the current target timing duration, determine the rendering state change information of the terminal device in the current timing cycle, and based on the rendering state change information, determine the timing result of the current timing cycle, and enter the next timing cycle.

[0128] For example, when the target application executes the current timing cycle, the first thread generates a timing command based on the current target timing duration and sends it to the timing component. The timing component starts timing according to the timing command. When the timing reaches the value corresponding to the current target timing duration, the timing component sends a timing end signal to the second thread. The target application determines whether the rendering state of the terminal device has changed at this time, generates rendering state change information, and determines the timing result of the current timing cycle based on the rendering state change information.

[0129] In addition, if the rendering status information changes, the timing result is determined based on the actual rendering time of the rendering page.

[0130] In one embodiment provided in this disclosure, in response to receiving a timing end signal sent by the timing component, the delay message is read from the preset storage space, and the timing result of the current timing period is determined based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message.

[0131] In practice, the timing end signal sent by the timing component to the second thread can actually be regarded as an enable signal for the second thread. After receiving the timing end signal, the second thread reads the delayed message from the delayed message queue. Here, the delayed message queue can be stored in a preset storage space, and the delayed message includes the first timestamp of the timing start corresponding to the current timing period.

[0132] The rendering state change information refers to whether the terminal device responds to user operations and changes the rendering state of a target page within the current time period. This includes, but is not limited to, at least one of the following: the first operation of switching the program corresponding to the target page from foreground rendering to background; the second operation of switching the target page from background to foreground rendering; and the third operation of completely closing the target page. Specifically, the first operation of switching the program corresponding to the target page from foreground rendering to background, and the second operation of switching the target page from background to foreground rendering, may not occur, may occur once, or may occur multiple times within a time period.

[0133] For example, taking a game as the target application, when a user triggers an idle reward operation, the target page of the game enters a timer state. When the user switches the target page of the game to the background, the terminal device responds to the user's operation by changing the rendering state of the target page to unrendered, thus the first operation mentioned above occurs. When the user switches back to the foreground, the rendering state of the terminal device changes to rendering, thus the second operation mentioned above occurs.

[0134] Among them, the rendering state change information of the terminal device can be sent from the main thread to the second thread after the rendering state of the terminal device changes.

[0135] For example, the main thread can monitor the rendering status of the target page on the terminal device; whenever the rendering status of the target page changes, it can detect the specific time of the change and record the time of the change as a third timestamp, and then generate rendering status change information based on the third timestamp and send it to the second thread.

[0136] The rendering state change information includes: a third timestamp when the rendering state changes, and the rendering state corresponding to the third timestamp.

[0137] Here, the rendering status corresponding to the third timestamp is used to indicate whether the terminal device renders the target page after the time corresponding to the third timestamp.

[0138] In this embodiment of the disclosure, such as Figure 2 As shown, a flowchart is also provided to determine the timing result of the current timing period based on the first timestamp of the start of the current timing period, the current target timing duration, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message. The flowchart includes the following steps S201 to S202, wherein:

[0139] S201: In response to the absence of rendering state change information indicating a change in the rendering state of the terminal device during the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period and the second timestamp of the current time.

[0140] If, during the execution of the current timing cycle, the second thread does not receive rendering state change information generated by the terminal device in response to a change in the rendering state of the target page, it indicates that the rendering state of the current target page is continuous. In this case, the actual timing duration and the current target timing duration received by the first thread in the current timing cycle are equal. In this case, the timing result can be determined directly based on the second timestamp of the time and the first timestamp of the start of the timing corresponding to the current timing cycle. The timing result indicates the actual timing duration.

[0141] Wherein, the actual timing duration T satisfies:

[0142] T = (t2 - t1)

[0143] Where t2 represents the second timestamp; t1 represents the first timestamp.

[0144] For example, the first thread of the target application determines the current target timeout duration of the first timeout period to be 10 seconds based on the preset timeout duration sent by the main thread. If the target page does not trigger the pause rendering state within this timeout period, the actual timeout duration is determined to be 10 seconds. For example, if the user triggers the timeout event at 12:30′20″, the first thread of the target application records the first timestamp as 12:30′20″ when it generates a delay message based on the current target timeout duration and sends it to the delay message queue. At the same time, the first thread generates a timeout command based on the current target timeout duration and sends it to the timeout component. The timeout component starts timing according to the timeout command and stops timing after 10 seconds. At this time, the timeout component sends a timeout stop signal to the second thread. The second thread records the second timestamp as 12:30′30″ upon receiving the timeout stop signal. The actual timeout duration is obtained by subtracting the first timestamp from the second timestamp.

[0145] S202: In response to obtaining rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device.

[0146] The rendering state change information includes: a third timestamp when the rendering state changes, and the rendering state corresponding to the third timestamp.

[0147] For example, the rendering state changes, including but not limited to switching the target application running the target page from foreground to background, and / or switching the target application running the target page from background back to foreground; or closing / opening the target page.

[0148] After determining the rendering state change information, in one embodiment provided in this disclosure, based on the rendering state corresponding to the third timestamp, and the first timestamp and the second timestamp, the target time period for the terminal device to render the target page is determined; based on the start time and end time of the target time period, the rendering duration corresponding to the target time period is determined; and based on the rendering duration corresponding to the target time period, the timing result is determined.

[0149] Here, the target time period for rendering the target page on the terminal device can be determined based on the rendering state corresponding to the third timestamp, as well as the first and second timestamps. The rendering duration corresponding to the target time period is determined based on the start and end times of the target time period. The timing result is then determined based on the rendering duration corresponding to the target time period.

[0150] The target time period refers to the time period during which the corresponding target page is rendered on the terminal device.

[0151] For example, the current target timeout duration of the current timing cycle executed by the target application is set to 10 seconds. The first thread of the target application generates a timing command based on the current target timeout duration and sends it to the timing component. The timing component starts timing based on the timing command. At the same time, the first thread generates a delay message based on the current target timeout duration and sends it to the delay message queue, and records the first timestamp of the start of rendering. When the target page starts rendering and 4 seconds have passed, the user switches the target application to run in the background. The terminal device responds to the user's operation and stops the rendering state of the target page. At this time, the third timestamp of the change of the rendering state of the target page from rendering to not rendering is recorded. Based on the third timestamp and the first timestamp, the target time period corresponding to the actual rendering of the target page can be determined. The duration of the target time period is 4 seconds.

[0152] If there are multiple target time periods within the current time period, i.e., the user performs multiple operations to change the rendering state, the durations corresponding to the target time periods can be accumulated to obtain the actual time duration corresponding to the current time period.

[0153] In one embodiment provided in this disclosure, the cumulative timing duration corresponding to the current timing period is determined based on the actual timing duration corresponding to the current timing period and the cumulative timing duration corresponding to the previous timing period; in response to the cumulative timing duration corresponding to the current timing period reaching a preset timing duration, a timing request is sent to the server; the timing request carries the cumulative timing duration corresponding to the current timing period, and the timing request is used to instruct the server to issue reward resources to the terminal device after determining that the total timing duration corresponding to multiple timing periods has reached a target duration based on the cumulative timing duration corresponding to the current timing period, wherein the preset timing duration is determined based on the target duration required by the server to issue the reward resources.

[0154] Here, if the total time required for the server to distribute the reward resources is 60 seconds, then the preset time duration can be set to 60 seconds, or preferably to a duration that is divisible by 60 seconds, such as 20 seconds, 10 seconds, or 5 seconds.

[0155] For example, the target application opens the target page based on a timed event triggered by the user. After the target page has been rendered for 30 seconds, that is, after the target duration has reached 30 seconds, resource rewards can be distributed to the target application used by the user, such as... Figure 3 As shown in the example diagram of the timer cycle for triggering resource rewards in a certain timer event provided in this disclosure, the solid part of the upper dashed and solid line segment indicates that the target page is in a rendering state at this time, the dashed part indicates that the target page is in a non-rendering state at this time, the triggering timer request point indicates that the preset timer duration of a timer cycle is met, and the lower dashed line segment indicates the current target timer duration of a timer cycle.

[0156] In the first timing cycle, assuming a preset timing duration of 10 seconds, the first thread of the target application determines the current target timing duration for that cycle based on the preset duration. It then generates a timing command based on this current target timing duration and sends it to the timing component. Simultaneously, a delay message is generated and sent to the delay message queue. The delay message carries the first timestamp of the target page starting rendering as 8:20′10″. After 4 seconds, the user switches the target application to background operation. The terminal device responds to the user's action by terminating the rendering of the target page. At this point, the terminating rendering state of the target page is recorded. The second timestamp is 8:20′14″. After 2 seconds, the user switches the target application to the foreground and runs it until the current target timeout ends. The third timestamp, which records the resumption of rendering, is 8:20′16″, and the fourth timestamp, which records the end of the timeout period, is 8:20′20″. At this point, the rendering duration of the target page in the first timeout period can be obtained, which is the actual timeout duration of the current timeout period. The cumulative timeout duration relative to the next timeout period is 8 seconds. Based on the actual timeout duration, the first thread determines the target timeout duration of the second timeout period to be 2 seconds.

[0157] In the second timing cycle, the first timestamp when the target page begins rendering is 8:20′20″. After 2 seconds, the actual duration of the current timing cycle plus the cumulative duration of the previous timing cycle reaches the preset timing duration. The fifth timestamp of the preset timing duration is 8:20′22″. At this time, the second thread of the target application sends a timing request to the server.

[0158] After receiving the timing request, the server determines the total timing duration based on the number of requests. That is, based on the preset timing duration of 10 seconds, when the number of requests reaches 3, the total timing duration determined by the number of requests reaches the target duration, and then the server distributes reward resources to the target application on the terminal device.

[0159] In addition, after the reward resources are distributed, the timing event ends, waiting for the user to trigger the next timing event. Therefore, after the server distributes the reward resources, it will also send a timing stop command to stop the timing component from timing.

[0160] In one embodiment provided in this disclosure, timing is stopped in response to receiving a timing stop command sent by the server.

[0161] For example, in response to receiving a timeout command from the server, the target application controls the timer component to stop timing, eliminates the delayed message queue, terminates the first and second threads, and releases system resources.

[0162] This disclosure also provides a specific example of timing, such as... Figure 4As shown, in a specific example of a timing method, a target application is deployed in a terminal device.

[0163] In response to a timed event being triggered, the target application's main thread generates a first thread, a second thread, and a delayed message queue.

[0164] Before the first timing cycle begins, the main thread sends the first timing cycle T to the first thread. The current target timing duration of timing cycle T is 20 seconds.

[0165] The first thread responds to the first timing period T sent by the main thread, generates a delay message M based on the timing duration of the first timing period T, records the timestamp t1, sends the delay message M to the delay message queue, and sends a timing instruction to the timing component, which carries the timing period T information.

[0166] After receiving the timing command, the timing component starts timing and, after the timing period T is reached, sends a message processing signal to the second thread to notify it to process the delay message M.

[0167] After receiving the delayed message M, the second thread calculates the cumulative timing duration of the first timing period T based on the timestamp t1 and the current terminal device timestamp t2. If the cumulative timing duration reaches the preset timing duration, a timing request is sent to the server.

[0168] After receiving the timing request from the terminal device, the server updates the total timing duration and checks if the updated total duration reaches the target timing duration of 10 minutes. If it does, a reward is issued to the terminal device. The server then sends a termination message to the second thread, destroys the delay message queue, and releases resources.

[0169] When the second thread receives the termination message from the server, it first destroys the first thread, and then destroys itself.

[0170] like Figure 5 As shown, before the delayed message M is read by the second thread, the main thread receives the event of the termination of rendering state, records the timestamp t2 when the rendering state is terminated, and sends a second signal to the second thread indicating that the rendering state of the target page has changed.

[0171] The second thread receives the message processing signal sent by the timing component, reads the delayed message M from the delayed message queue, and responds to the reading of message M. Based on the second signal, it determines that the current rendering state of the target page is unrendered and calculates the rendering duration of the target time period.

[0172] The rendering durations of all target time periods within the timing period T are summed to obtain the actual timing duration D.

[0173] d1: If the actual timing duration D is less than the preset timing duration, then according to T1=TD, a new timing period T1 is obtained, and the timing period T1 is sent to the first thread.

[0174] The first thread responds to the receipt of a new timing period T1 and generates a new delay message M1 based on the new timing period T1.

[0175] d2: If the actual timing duration D equals the preset timing duration, then the current target timing duration of the new timing period T1 is the preset timing duration. Upon receiving the new timing period T1, the first thread generates a new delay message M2.

[0176] Before M1 or M2 is read by the second thread, the main thread receives the third signal that the rendering state has been restored, records the third timestamp t3 when the rendering state is restored, and sends the third signal that the rendering state has changed to the second thread.

[0177] The second thread receives the message processing signal sent by the timing component, reads the delayed message M1 or M2 from the delayed message queue, responds to the read message, and determines the current rendering state of the target page as a restart rendering state based on the third signal. Based on the start timestamp t1, the timestamp t2 of the stopped rendering state, the timestamp t3 of the resumed rendering state, and the timestamp t4 of the current terminal device, it determines the target time period for the terminal device to render the target page, thereby determining the rendering duration corresponding to the target time period. Based on the rendering duration corresponding to the target time period, the actual timing duration D is obtained.

[0178] D = (t4 - t3) + (t2 - t1)

[0179] The target time period refers to the time period during which the corresponding target page is rendered on the terminal device.

[0180] After determining the target time period, the durations corresponding to each target time period are summed up to obtain the actual rendering duration corresponding to the current timing cycle.

[0181] Then, the actual rendering time and the currently recorded historical time duration are added together to obtain the current cumulative time duration D.

[0182] Based on the same inventive concept, such as Figure 6As shown in the embodiments of this disclosure, a resource allocation system is also provided, including: a terminal device 602 and a server 601; the terminal device 602 includes a first thread 603 and a second thread 604; the terminal device 602 is used to execute the following process in each of multiple timing cycles: the first thread 603, in response to receiving the timing duration of the current timing cycle, generates a delay message and a timing instruction corresponding to the timing duration, sends the delay message to the delay message queue, and sends the timing instruction to the timing component; the second thread 604, in response to receiving a timing end signal from the timing component based on the timing duration, reads the delay message from the delay message queue, and determines the timing result based on the first timestamp of the timing start corresponding to the current timing cycle, the second timestamp of the current time, and the rendering state change information of the terminal device 602; in response to the current accumulated timing duration reaching the preset timing duration, sends a timing request to the server 601. Terminal device 602 is used to determine the current target cumulative time duration in response to receiving a time duration request sent by terminal device 602; and to issue target resources to terminal device 602 in response to the current target cumulative time duration reaching a preset time duration.

[0183] In this embodiment, the specific process by which the first thread 603 and the second thread 604 in the terminal device 602 execute multiple timing cycles is similar to the timing method described in any of the above embodiments. For details, please refer to the above... Figures 1-5 The specific description of the corresponding embodiments will not be repeated here.

[0184] In this embodiment of the disclosure, the terminal device determines the timing result based on its rendering state change information. Only after the current cumulative timing duration reaches the preset timing duration will it send a timing request to the server, thereby enabling accurate timing even when the rendering state of the terminal device changes.

[0185] In addition, the current target time duration for each timing cycle is determined based on the timing result of the previous timing cycle and the target time duration. Therefore, it can adapt to the complex changes in the rendering environment of the terminal device, achieve accurate timing, improve the reliability of timing, and make the timing and distribution of virtual resources based on the above timing method more accurate.

[0186] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0187] Based on the same inventive concept, this disclosure also provides a timing device corresponding to the timing method. Since the principle of the device in this disclosure for solving the problem is similar to the timing method described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0188] Reference Figure 7 The diagram shown is a schematic of a timing device provided in an embodiment of this disclosure, which is applied to a terminal device;

[0189] The timing device includes:

[0190] The first determining module 701 is used to determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period;

[0191] The timing module 702 is used to perform timing based on the current target timing duration;

[0192] The second determining module 703 is used to determine the rendering state change information of the terminal device in the current timing cycle in response to the timing reaching the current target timing duration, and to determine the timing result of the current timing cycle based on the rendering state change information, and to enter the next timing cycle.

[0193] In an optional implementation, when the first determining module 701 responds to the current timing period being the first timing period and determines the current target timing duration corresponding to the current timing period, it is used to:

[0194] Receive the preset timing duration sent by the target application, and determine the preset timing duration as the current target timing duration;

[0195] When the first determining module 701 determines the current target timing duration corresponding to the current timing period in response to the current timing period being not the first counting period, it is specifically used for:

[0196] The current target timing duration is determined based on the timing result of the previous timing cycle and the target timing duration of the previous timing cycle.

[0197] In an optional implementation, when the first determining module 701 determines the current target timing duration based on the timing result of the previous timing period and the target timing duration of the previous timing period, it is further configured to:

[0198] Determine whether the actual timing duration indicated by the timing result corresponding to the previous timing cycle is equal to the target timing duration of the previous timing cycle;

[0199] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is the same as the target timing duration of the previous timing period, the preset timing duration is determined as the current target timing duration;

[0200] In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is less than the target timing duration of the previous timing period, the difference between the target timing duration of the previous timing period and the actual timing duration indicated by the timing result corresponding to the previous timing period is determined as the current target timing duration.

[0201] In an optional implementation, when the timing module 702 is timing based on the current target duration, it is used to:

[0202] Based on the current target time duration, a timing instruction corresponding to the current target time duration is generated; the timing instruction is sent to the timing component so that the timing component performs timing based on the current target time duration carried in the timing instruction.

[0203] In an optional embodiment, the timing device further includes a message generation module 704, used for:

[0204] Generate a delay message corresponding to the current target timing duration, and store the delay message in a preset storage space; the delay message carries a first timestamp of the start of timing corresponding to the current timing period;

[0205] When the second determining module 703 determines the rendering state change information of the terminal device in the current timing period in response to the timing reaching the current target timing duration, and determines the timing result of the current timing period based on the rendering state change information, it is used to:

[0206] In response to receiving the timing end signal sent by the timing component, the delay message is read from the preset storage space, and the timing result of the current timing period is determined based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message.

[0207] In an optional implementation, the second determining module 703, when determining the timing result of the current timing period based on the first timestamp of the start of timing corresponding to the current timing period, the current target timing duration, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message, is further configured to:

[0208] In response to the absence of rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period and the second timestamp of the current time.

[0209] In response to obtaining rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device.

[0210] In an optional implementation, the second determining module 703, when determining the timing result based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device obtained in the current timing period, is further configured to:

[0211] Based on the rendering status corresponding to the third timestamp, as well as the first timestamp and the second timestamp, the target time period for the terminal device to render the target page is determined;

[0212] Based on the start and end times of the target time period, the rendering duration corresponding to the target time period is determined;

[0213] The timing result is determined based on the rendering duration corresponding to the target time period.

[0214] In an optional embodiment, the device further includes a first response module 706, which, when determining the cumulative timing duration corresponding to the current timing period based on the actual timing duration corresponding to the current timing period and the cumulative timing duration corresponding to the previous timing period, is configured to:

[0215] In response to the cumulative time duration corresponding to the current time period reaching a preset time duration, a time request is sent to the server. The time request carries the cumulative time duration corresponding to the current time period. The time request is used to instruct the server to issue reward resources to the terminal device after determining that the total time duration corresponding to multiple time periods has reached the target time duration based on the cumulative time duration corresponding to the current time period. The preset time duration is determined based on the target time duration required by the server to issue the reward resources.

[0216] In an optional embodiment, the device further includes a second response module 705, configured to:

[0217] In response to receiving a timer stop command from the server, the timer is stopped.

[0218] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0219] This disclosure also provides a computer device, such as... Figure 8 The diagram shown is a schematic representation of a computer device structure provided in an embodiment of this disclosure, including:

[0220] A processor 801 and a memory 802; the memory 802 stores machine-readable instructions executable by the processor 801, and the processor 801 executes the machine-readable instructions stored in the memory 802. When the machine-readable instructions are executed by the processor 801, the processor 801 performs the following steps:

[0221] In response to a triggered timing event, the following procedure is performed in each of the multiple timing cycles:

[0222] Determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period;

[0223] Timing is performed based on the current target duration.

[0224] In response to the timing reaching the current target timing duration, the rendering state change information of the terminal device in the current timing cycle is determined, and based on the rendering state change information, the timing result of the current timing cycle is determined, and the next timing cycle is entered.

[0225] or,

[0226] The following procedure is performed in each of the multiple timing cycles:

[0227] The first thread, in response to receiving the timing duration of the current timing period, generates a delay message and a timing instruction corresponding to the timing duration, sends the delay message to the delay message queue, and sends the timing instruction to the timing component; the second thread, in response to receiving a timing end signal from the timing component based on the timing duration, reads the delay message from the delay message queue, and determines the current cumulative timing duration based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device; in response to the current cumulative timing duration reaching a preset duration threshold, sends a timing request to the server.

[0228] The aforementioned memory 802 includes a main memory 8021 and an external memory 8022. The main memory 8021, also known as internal memory, is used to temporarily store the computational data in the processor 801, as well as the data exchanged with external memory 8022 such as a hard disk. The processor 801 exchanges data with the external memory 8022 through the main memory 8021.

[0229] The specific execution process of the above instructions can be referred to the steps of the timing method described in the embodiments of this disclosure, and will not be repeated here.

[0230] This disclosure also provides a computer-readable storage medium storing a computer program that, when rendered by a processor, executes the steps of the timing method described in the above-described method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0231] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the timing method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0232] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0233] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0234] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0235] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0236] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0237] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A timing method, characterized in that, Applied to terminal devices; the method includes: In response to a triggered timing event, the following procedure is performed in each of the multiple timing cycles: Determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period; wherein the timing result includes: the actual timing duration corresponding to the timing period; Timing is performed based on the current target duration. In response to the timing reaching the current target timing duration, the system determines the rendering state change information of the terminal device in the current timing cycle, and based on the rendering state change information, determines the timing result of the current timing cycle, and proceeds to the next timing cycle. Wherein, in response to the current timing period being a non-first counting period, determining the current target timing duration corresponding to the current timing period includes: The current target timing duration is determined based on the timing result of the previous timing cycle and the target timing duration of the previous timing cycle.

2. The method according to claim 1, characterized in that, In response to the current timing period being the first timing period, determining the current target timing duration corresponding to the current timing period includes: Receive the preset timing duration sent by the target application, and determine the preset timing duration as the current target timing duration.

3. The method according to claim 1, characterized in that, Determining the current target timing duration based on the timing result of the previous timing period and the target timing duration of the previous timing period includes: Determine whether the actual timing duration indicated by the timing result corresponding to the previous timing cycle is equal to the target timing duration of the previous timing cycle; In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is the same as the target timing duration of the previous timing period, the preset timing duration is determined as the current target timing duration; In response to the fact that the actual timing duration indicated by the timing result corresponding to the previous timing period is less than the target timing duration of the previous timing period, the difference between the target timing duration of the previous timing period and the actual timing duration indicated by the timing result corresponding to the previous timing period is determined as the current target timing duration.

4. The method according to any one of claims 1-3, characterized in that, The timing based on the current target duration includes: Based on the current target time duration, a timing instruction corresponding to the current target time duration is generated; the timing instruction is sent to the timing component so that the timing component performs timing based on the current target time duration carried in the timing instruction.

5. The method according to claim 4, characterized in that, The method further includes: generating a delay message corresponding to the current target timing duration, and storing the delay message in a preset storage space; the delay message carries a first timestamp of the start of timing corresponding to the current timing period; In response to the timing reaching the current target timing duration, the system determines the rendering state change information of the terminal device in the current timing period, and determines the timing result of the current timing period based on the rendering state change information, including: In response to receiving the timing end signal sent by the timing component, the delay message is read from the preset storage space, and the timing result of the current timing period is determined based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message.

6. The timing method according to claim 5, characterized in that, The determination of the timing result for the current timing period based on the first timestamp of the start of timing corresponding to the current timing period, the current target timing duration, the second timestamp of the current time, and the rendering state change information of the terminal device carried in the delay message includes: In response to the absence of rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period and the second timestamp of the current time. In response to obtaining rendering state change information of the terminal device in the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device.

7. The timing method according to claim 6, characterized in that, The rendering state change information includes: a third timestamp when the rendering state changes, and the rendering state corresponding to the third timestamp.

8. The timing method according to claim 7, characterized in that, In response to obtaining rendering state change information indicating a change in the rendering state of the terminal device during the current timing period, the timing result is determined based on the first timestamp of the start of timing corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device, including: Based on the rendering status corresponding to the third timestamp, as well as the first timestamp and the second timestamp, the target time period for the terminal device to render the target page is determined; Based on the start and end times of the target time period, the rendering duration corresponding to the target time period is determined; The timing result is determined based on the rendering duration corresponding to the target time period.

9. The timing method according to claim 8, characterized in that, The method further includes: Based on the actual timing duration corresponding to the current timing cycle and the cumulative timing duration corresponding to the previous timing cycle, the cumulative timing duration corresponding to the current timing cycle is determined. In response to the cumulative time duration corresponding to the current time period reaching a preset time duration, a time request is sent to the server. The time request carries the cumulative time duration corresponding to the current time period. The time request is used to instruct the server to issue reward resources to the terminal device after determining that the total time duration corresponding to multiple time periods has reached the target time duration based on the cumulative time duration corresponding to the current time period. The preset time duration is determined based on the target time duration required by the server to issue the reward resources.

10. The timing method according to claim 9, characterized in that, The method further includes: In response to receiving a timer stop command from the server, the timer is stopped.

11. A timing device, characterized in that, Applied to a terminal device, the timing device, in response to a triggered timing event, performs the following process in each of a plurality of timing cycles: The first determining module is used to determine the current target timing duration corresponding to the current timing period; wherein the current target timing duration is determined based on a preset timing duration or based on the timing result of the previous timing period corresponding to the current timing period; wherein the timing result includes: the actual timing duration corresponding to the timing period; The timing module is used to perform timing based on the current target timing duration; The second determining module is used to, in response to the timing reaching the current target timing duration, determine the rendering state change information of the terminal device in the current timing cycle, and based on the rendering state change information, determine the timing result of the current timing cycle, and proceed to the next timing cycle. Wherein, in response to the current timing period being a non-first counting period, determining the current target timing duration corresponding to the current timing period includes: The current target timing duration is determined based on the timing result of the previous timing cycle and the target timing duration of the previous timing cycle.

12. A resource allocation system, characterized in that, include: Terminal device and server; the terminal device includes a first thread and a second thread; The terminal device is configured to perform the following process in each of a plurality of timing cycles: The first thread, in response to receiving the current target timeout duration of the current timing period, generates a delay message and a timing instruction corresponding to the current target timeout duration, sends the delay message to the delay message queue, and sends the timing instruction to the timing component; the second thread, in response to receiving the timing end signal from the timing component based on the current target timeout duration, reads the delay message from the delay message queue, and determines the current cumulative timeout duration based on the first timestamp of the timing start corresponding to the current timing period, the second timestamp of the current time, and the rendering state change information of the terminal device; In response to the current cumulative timeout reaching a preset timeout threshold, a timeout request is sent to the server. The current target timeout is determined based on the preset timeout or based on the timeout result of the previous timeout corresponding to the current timeout period. The timeout result includes the actual timeout duration corresponding to the timeout period. In response to the fact that the current timing period is not the first timing period, the current target timing duration is determined based on the timing result of the previous timing period and the target timing duration of the previous timing period.

13. A computer device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, the processor executing the machine-readable instructions stored in the memory, wherein when the machine-readable instructions are executed by the processor, the processor performs the steps of the periodic task timing method as described in any one of claims 1 to 10, or the resource allocation system as described in claim 12.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when rendered by a computer device, executes the steps of the periodic task timing method as described in any one of claims 1 to 10, or the resource allocation system as described in claim 12.