CN109445954B - Timing task execution method, terminal device and storage medium - Google Patents

Timing task execution method, terminal device and storage medium Download PDF

Info

Publication number
CN109445954B
CN109445954B CN201811054877.3A CN201811054877A CN109445954B CN 109445954 B CN109445954 B CN 109445954B CN 201811054877 A CN201811054877 A CN 201811054877A CN 109445954 B CN109445954 B CN 109445954B
Authority
CN
China
Prior art keywords
task
thread
timing task
timing
timed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811054877.3A
Other languages
Chinese (zh)
Other versions
CN109445954A (en
Inventor
丁雨成
潘泉锦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
PAX Computer Technology Shenzhen Co Ltd
Original Assignee
PAX Computer Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by PAX Computer Technology Shenzhen Co Ltd filed Critical PAX Computer Technology Shenzhen Co Ltd
Priority to CN201811054877.3A priority Critical patent/CN109445954B/en
Publication of CN109445954A publication Critical patent/CN109445954A/en
Application granted granted Critical
Publication of CN109445954B publication Critical patent/CN109445954B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07GREGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
    • G07G1/00Cash registers
    • G07G1/12Cash registers electronically operated

Landscapes

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

Abstract

The application is applicable to the technical field of multithreading, and provides a timing task execution method, terminal equipment and a computer readable storage medium, wherein the method comprises the following steps: the method comprises the steps of creating a timing task thread outside a JavaScript main thread, registering a timing task in the timing task thread, polling the registered timing task in the timing task thread to obtain a matched timing task, sending scheduling information corresponding to the matched timing task to the main thread after the matched timing task is obtained, executing the timing task corresponding to the scheduling information by the main thread according to the monitored scheduling information, and executing the timing task while executing main services in POS application based on WEB technology.

Description

Timing task execution method, terminal device and storage medium
Technical Field
The present application belongs to the field of multithreading technology, and in particular, relates to a method for executing a timing task, a terminal device, and a computer-readable storage medium.
Background
The point of sale (POS) is a multifunctional terminal, and is installed in special commercial tenant and acceptance network of credit card and connected with computer to form network to implement automatic electronic fund transfer.
At present, POS application is mostly based on a WEB technology, and a programming language used in the WEB technology is JavaScript which is characterized in that a single thread execution program cannot execute certain timing tasks while executing main services.
Disclosure of Invention
In view of this, embodiments of the present application provide a timing task execution method, a terminal device, and a computer-readable storage medium, so as to solve the problem that a POS application based on a WEB technology cannot execute a timing task while executing a main service.
A first aspect of an embodiment of the present application provides a method for executing a timing task, including:
creating a timing task thread outside a JavaScript main thread, and registering a timing task in the timing task thread;
polling the registered timing tasks in the timing task thread to obtain matched timing tasks;
after the matched timing task is obtained, sending scheduling information corresponding to the matched timing task to the main thread;
and the main thread executes a timing task corresponding to the scheduling message according to the monitored scheduling message.
A second aspect of an embodiment of the present application provides a terminal device, including:
the device comprises a registering unit, a processing unit and a processing unit, wherein the registering unit is used for creating a timing task thread outside a JavaScript main thread and registering a timing task in the timing task thread;
the polling unit is used for polling the registered timing task in the timing task thread to obtain a matched timing task;
the scheduling information sending unit is used for sending scheduling information corresponding to the matched timing task to the main thread after the matched timing task is obtained;
and the execution unit is used for executing the timing task corresponding to the scheduling message by the main thread according to the monitored scheduling message.
A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method provided in the first aspect of the embodiment of the present application when executing the computer program.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium storing a computer program which, when executed by one or more processors, performs the steps of the method provided by the first aspect of embodiments of the present application.
A fifth aspect of embodiments of the present application provides a computer program product comprising a computer program that, when executed by one or more processors, performs the steps of the method provided by the first aspect of embodiments of the present application.
The embodiment of the application provides a method for executing a timed task, which comprises the steps of establishing a timed task thread outside a JavaScript main thread, registering the timed task in the timed task thread, polling the registered timed task in the timed task thread to obtain a matched timed task, sending scheduling information corresponding to the matched timed task to the main thread after the matched timed task is obtained, and executing the timed task corresponding to the scheduling information by the main thread according to the monitored scheduling information. Because the programs related to the timing task run in the timing task thread, the main program codes in the main thread are not blocked, loosely coupled and easy to integrate; the timed task is arranged in the timed task thread, so that the constraint of a single thread running environment is eliminated, a trigger scheduling mechanism of the timed task is realized by multi-thread message synchronization, and a plurality of timed tasks can be run in the timed task thread at the same time.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic flowchart of an architecture of a method for executing a timed task, and a main thread and a timed task thread in the architecture according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for executing a timing task according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating another method for executing a timing task according to an embodiment of the present application;
fig. 4 is a schematic block diagram of a terminal device provided in an embodiment of the present application;
fig. 5 is a schematic block diagram of another terminal device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
To explain the technical solution described in the present application, the architecture diagram of the embodiment of the present application is first explained. As shown in fig. 1, for the architecture diagram of the execution method of the timing task provided in the embodiment of the present application, the execution method of the timing task provided in the embodiment of the present application needs to create an independently running Web Workers thread environment outside a JavaScript main thread, an interface for creating a Web Workers thread object is provided in a browser, and the Web Workers thread outside the JavaScript main thread is named as a timing task thread. Fig. 1 also depicts a schematic flow diagram of the main thread and the timed task thread corresponding to respective sides. The method comprises the steps that a timed task thread object can be created and started on one side of a JavaScript main thread, a timed task can also be registered, the timed task runs in the timed task thread, a scheduling message is sent to the main thread after the timed task with the timestamp consistent with the current time is polled in the timed task thread, and the main thread monitors the scheduling message of the timed task and executes the related timed task.
A regularly scheduled JavaScript program can run in the timed task thread. The program may be an automatic settlement, timed alignment, etc. task in the POS service. Certainly, the timing task runs in the timing task thread, and the main program code in the main thread is not blocked, loosely coupled and easy to integrate. And the timing task is arranged in the timing task thread, so that the constraint of a single thread running environment is eliminated, and a trigger scheduling mechanism of the timing task is realized by multi-thread message synchronization, for example, when the timing task thread monitors the timing task to be executed, the timing task thread sends scheduling information to the main thread, the main thread monitors the scheduling information and executes the timing task related to the scheduling information, so that the timing task thread can simultaneously support a plurality of timing tasks. Of course, in order to further improve the multithreading mechanism, the timed task thread may provide various interfaces for registering the timed task, updating the information of the timed task, closing or deleting the timed task, and the like. The following description will be made by way of specific examples.
Fig. 2 is a schematic implementation flowchart of a method for executing a timing task according to an embodiment of the present application, where as shown in the figure, the method may include the following steps:
step S201, a timed task thread is created outside the JavaScript main thread, and a timed task is registered in the timed task thread.
In the embodiment of the application, in order to be able to execute some timing tasks in addition to the running main program task, a timing task thread needs to be created in addition to a JavaScript main thread, an interface for creating a Web Workers thread object is provided in the browser, and an independently running Web Workers thread environment can be created in addition to the main thread based on the interface.
As another embodiment of the present application, the creating a timed task thread outside the JavaScript main thread includes:
and establishing a timing task thread object based on Web works of the browser, and starting a timing task thread through the timing task thread object.
In the embodiment of the present application, after the timed task thread object is created, the timed task thread needs to be started by the timed task thread object. After the timed task thread is started, at least one timed task needs to be set in the timed task thread. Therefore, the timed task thread provides a timed task registration function, and also provides a timed task update function, a timed task closing function or a timed task deleting function for better managing the registered timed tasks. Correspondingly, an interface is also required to be provided, and the provided interface is used for realizing the functions.
As another embodiment of the present application, the registering a timed task in the timed task thread includes:
calling a registration interface provided by the timed task thread object, and sending registration information to the timed task thread to register the timed task, wherein the registration information comprises: the name of the timed task and the trigger event of the timed task.
After the timed task is registered in the timed task thread, the method further comprises the following steps:
calling an updating interface provided by the timed task thread object, and sending updating information to the timed task thread so as to update the triggering event of the timed task corresponding to the updating information;
and calling a closing interface provided by the timed task thread object, and sending closing information to the timed task thread so as to close the timed task corresponding to the closing information.
In the embodiment of the present application, different interfaces may be provided for different functions, and then different functions may be implemented based on the different interfaces. When registering a timed task, the name of the timed task and a trigger event of the timed task may be sent to the timed task thread to register the timed task in the timed task thread. Similarly, when the timing task is updated, the trigger event of the timing task to be updated needs to be sent to the timing task thread. Then, when the timing task is closed or deleted, corresponding information is sent, and the closing or deletion of the specified timing task can be realized.
Step S202, polling the registered timing task in the timing task thread to obtain the matched timing task.
In embodiments of the present application, registered timed tasks may be viewed next to each other in a timed task thread to obtain matching timed tasks. The trigger event of the timing task comprises a time stamp of the timing task;
polling the registered timing task in the timing task thread to obtain a matched timing task comprises:
running a timer in the timed task thread, and polling a timestamp of the registered timed task based on the timer;
and if the timing task with the timestamp consistent with the current time is polled, determining the timing task with the timestamp consistent with the current time as the matched timing task.
In this embodiment of the present application, a timer interface setInterval provided by the web browser may be used, and the timestamps of all registered timing tasks are automatically detected and polled every second, and compared with the current time, the timing task with the consistent time is the matched timing task.
Step S203, after obtaining the matched timed task, sending scheduling information corresponding to the matched timed task to the main thread.
In the embodiment of the present application, although the timed task thread can determine the currently to-be-executed timed task, the main thread is required to execute the currently to-be-executed timed task, and therefore, data interaction is also required between the main thread and the timed task thread. After the timing task thread determines the currently matched timing task, a timing task scheduling message needs to be sent to the main thread through the Web Workers object.
And step S204, the main thread executes a timing task corresponding to the scheduling message according to the monitored scheduling message.
In the embodiment of the application, the main thread calls a timed task thread object interface to send data (registration, updating, closing or deleting) to a given timed task thread; meanwhile, the main thread monitors scheduling information of the timing task issued by the timing task thread through the object, and executes the timing task corresponding to the scheduling information after receiving the scheduling information.
Because the programs related to the timing task run in the timing task thread, the main program codes in the main thread are not blocked, loosely coupled and easy to integrate; the timed task is arranged in the timed task thread, so that the constraint of a single thread running environment is eliminated, a trigger scheduling mechanism of the timed task is realized by multi-thread message synchronization, and a plurality of timed tasks can be run in the timed task thread at the same time.
Fig. 3 is a schematic implementation flow diagram of another method for executing a timing task according to an embodiment of the present application, and as shown in the figure, the method may include the following steps:
step S301, a timed task thread object is created based on Web works of the browser, and a timed task thread is started through the timed task thread object.
This step can refer to the related description in the embodiment shown in fig. 1, and is not described herein again.
Step S302, a registration interface provided by the timing task thread object is called, POS self-service settlement registration information is sent to the timing task thread to register a POS self-service settlement task, and the POS self-service settlement registration information comprises: time stamp of POS self-service settlement.
In the embodiment of the application, a POS self-settlement task is taken as an example for explanation, where the POS self-settlement task refers to a service requirement that a POS settlement service is triggered at a specific time every day, and a registration interface provided by the timed task thread object may be called to send a time stamp of POS self-settlement to the timed task thread to register the POS self-settlement task. Of course, in practical application, other timing tasks may also be registered. I.e. there may be multiple timed tasks in a timed task thread.
Step S303, polling the registered timing tasks in the timing task thread, and determining the matched timing task as a POS self-settlement task when the time stamp of the POS self-settlement is consistent with the current time.
In the embodiment of the application, the registered timed tasks are polled in the timed task thread, for example, all the registered timed tasks are polled every second by a timer running in the timed task thread, and in the polling process, if the timestamp of the polled POS self-service settlement task is consistent with the current time, the POS self-service settlement task is determined to be the matched timed task.
Step S304, sending scheduling information of POS self-service settlement to the main thread;
and step S305, the main thread executes a POS self-settlement task according to the monitored dispatching information of the POS self-settlement.
In the embodiment of the application, the main thread is still required to execute the POS self-settlement task, and therefore, after it is determined that the matched timing task is the POS self-settlement task in the timing task thread, scheduling information of the POS self-settlement needs to be sent to the main thread. And after the main thread monitors the scheduling information of the POS self-service settlement, executing the POS self-service settlement task.
The embodiment of the application takes a POS self-service settlement task as an example to explain how to execute a timing task while executing a main service in a POS application based on a WEB technology by using the execution method of the timing task provided by the embodiment of the application, and in practical application, the timing task running in a timing task thread may also be another timing task.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 4 is a schematic block diagram of a terminal device provided in an embodiment of the present application, and only a part related to the embodiment of the present application is shown for convenience of description.
The terminal device 4 may be a software unit, a hardware unit, or a combination of software and hardware connected to a conventional terminal device such as a POS machine or a computer, or may be a terminal device such as a standalone POS machine or a computer.
The terminal device 4 includes:
a registering unit 41, configured to create a timed task thread outside a JavaScript main thread, and register a timed task in the timed task thread;
the polling unit 42 is configured to poll the registered timing task in the timing task thread to obtain a matched timing task;
a scheduling information sending unit 43, configured to send scheduling information corresponding to the matched timing task to the main thread after the matched timing task is obtained;
and the execution unit 44 is configured to execute, by the main thread, a timing task corresponding to the scheduling message according to the monitored scheduling message.
As another embodiment of the present application, the registering unit 41 is further configured to:
and establishing a timing task thread object based on Web works of the browser, and starting a timing task thread through the timing task thread object.
As another embodiment of the present application, the registering unit 41 is further configured to:
calling a registration interface provided by the timed task thread object, and sending registration information to the timed task thread to register the timed task, wherein the registration information comprises: the name of the timed task and the trigger event of the timed task.
As another embodiment of the present application, the terminal device 4 further includes:
an updating unit 45, configured to invoke an updating interface provided by the timed task thread object, and send updating information to the timed task thread, so as to update a trigger event of the timed task corresponding to the updating information;
a closing unit 46, configured to invoke a closing interface provided by the timed task thread object, and send closing information to the timed task thread, so as to close the timed task corresponding to the closing information.
As another embodiment of the present application, the trigger event of the timed task includes a timestamp of the timed task;
the polling unit 42 is further configured to:
running a timer in the timed task thread, and polling a timestamp of the registered timed task based on the timer;
and if the timing task with the timestamp consistent with the current time is polled, determining the timing task with the timestamp consistent with the current time as the matched timing task.
As another embodiment of the present application, the registering unit 41 is further configured to:
calling a registration interface provided by the timed task thread object, and sending POS self-settlement registration information to the timed task thread to register a POS self-settlement task, wherein the POS self-settlement registration information comprises: time stamp of POS self-service settlement.
As another embodiment of the present application, the scheduling information sending unit 43 is further configured to:
when the time stamp of the POS self-service settlement is consistent with the current time, sending scheduling information of the POS self-service settlement to the main thread;
as another embodiment of the present application, the executing unit 44 is further configured to:
and the main thread executes the POS self-settlement task according to the monitored dispatching message of the POS self-settlement.
It is obvious to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional units and modules is merely used as an example, and in practical applications, the foregoing function distribution may be performed by different functional units and modules as needed, that is, the internal structure of the terminal device is divided into different functional units or modules to perform all or part of the above-described functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the terminal device may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Fig. 5 is a schematic block diagram of a terminal device according to another embodiment of the present application. As shown in fig. 5, the terminal device 5 of this embodiment may be a computer connected to an existing terminal device, and may include: one or more processors 50, a memory 51 and a computer program 52 stored in said memory 51 and executable on said processors 50. The processor 50, when executing the computer program 52, implements the steps in the various method embodiments described above, such as the steps S101 to S103 shown in fig. 1. Alternatively, the processor 50, when executing the computer program 52, implements the functions of the modules/units in the terminal device embodiment described above, such as the functions of the modules 41 to 43 shown in fig. 4.
Illustratively, the computer program 52 may be partitioned into one or more modules/units, which are stored in the memory 51 and executed by the processor 50 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 52 in the terminal device 5. For example, the computer program 52 may be divided into a registration unit, a polling unit, a scheduling information transmission unit, and an execution unit.
The device comprises a registering unit, a processing unit and a processing unit, wherein the registering unit is used for creating a timing task thread outside a JavaScript main thread and registering a timing task in the timing task thread;
the polling unit is used for polling the registered timing task in the timing task thread to obtain a matched timing task;
the scheduling information sending unit is used for sending scheduling information corresponding to the matched timing task to the main thread after the matched timing task is obtained;
and the execution unit is used for executing the timing task corresponding to the scheduling message by the main thread according to the monitored scheduling message.
Other modules can refer to the description of the embodiment shown in fig. 4, and are not described again here.
The terminal device includes, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that fig. 5 is only one example of a terminal device 5 and does not constitute a limitation of the terminal device 5 and may include more or less components than those shown, or combine certain components, or different components, for example, the terminal device may also include input devices, output devices, network access devices, buses, etc.
The Processor 50 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or a memory of the terminal device 5. The memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 5. Further, the memory 51 may also include both an internal storage unit and an external storage device of the terminal device 5. The memory 51 is used for storing the computer program and other programs and data required by the terminal device. The memory 51 may also be used to temporarily store data that has been output or is to be output.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed terminal device and method may be implemented in other ways. For example, the above-described terminal device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical function division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media which may not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (7)

1. A method for executing timing tasks of POS application based on WEB technology is characterized by comprising the following steps:
creating a timing task thread outside a JavaScript main thread, and registering a timing task in the timing task thread; the timing task thread is a web workers thread;
polling the registered timing tasks in the timing task thread to obtain matched timing tasks, wherein the polling comprises the following steps: running a timer in the timed task thread, and polling a timestamp of the registered timed task based on the timer; if the timing task with the timestamp consistent with the current time is polled, determining the timing task with the timestamp consistent with the current time as a matched timing task; the trigger event of the timing task comprises a time stamp of the timing task;
after the matched timing task is obtained, sending scheduling information corresponding to the matched timing task to the main thread;
the main thread executes a timing task corresponding to the scheduling message according to the monitored scheduling message;
the registering of the timed task in the timed task thread comprises:
calling a registration interface provided by the timed task thread object, sending registration information to the timed task thread to register the timed task, specifically: calling a registration interface provided by the timed task thread object, and sending POS self-settlement registration information to the timed task thread to register a POS self-settlement task, wherein the POS self-settlement registration information comprises: a POS self-settlement timestamp; wherein the registration information includes: the name of the timing task and a trigger event of the timing task; the POS self-service settlement task refers to that the service requires triggering POS settlement service at a specific time every day.
2. The method of claim 1, wherein creating a timed task thread outside of a JavaScript main thread comprises:
and establishing a timing task thread object based on Web works of the browser, and starting a timing task thread through the timing task thread object.
3. The method of executing a timed task according to claim 1, after registering the timed task in the timed task thread, further comprising:
calling an updating interface provided by the timed task thread object, and sending updating information to the timed task thread so as to update the triggering event of the timed task corresponding to the updating information;
and calling a closing interface provided by the timed task thread object, and sending closing information to the timed task thread so as to close the timed task corresponding to the closing information.
4. The method for executing the timed task according to claim 1, wherein the sending scheduling information corresponding to the matched timed task to the main thread after obtaining the matched timed task comprises:
when the time stamp of the POS self-service settlement is consistent with the current time, sending scheduling information of the POS self-service settlement to the main thread;
correspondingly, the executing, by the main thread, the timing task corresponding to the scheduling message according to the monitored scheduling message includes:
and the main thread executes the POS self-settlement task according to the monitored dispatching message of the POS self-settlement.
5. A terminal device of POS application based on WEB technique is characterized in that the terminal device comprises:
the device comprises a registering unit, a processing unit and a processing unit, wherein the registering unit is used for creating a timing task thread outside a JavaScript main thread and registering a timing task in the timing task thread; the timing task thread is a web workers thread;
the polling unit is used for polling the registered timing task in the timing task thread to obtain a matched timing task;
the scheduling information sending unit is used for sending scheduling information corresponding to the matched timing task to the main thread after the matched timing task is obtained;
the execution unit is used for executing a timing task corresponding to the scheduling message by the main thread according to the monitored scheduling message;
the polling unit is further configured to:
running a timer in the timed task thread, and polling a timestamp of the registered timed task based on the timer; if the timing task with the timestamp consistent with the current time is polled, determining the timing task with the timestamp consistent with the current time as a matched timing task; the trigger event of the timing task comprises a time stamp of the timing task;
the registration unit is further configured to:
calling a registration interface provided by the timed task thread object, sending registration information to the timed task thread to register the timed task, specifically: calling a registration interface provided by the timed task thread object, and sending POS self-settlement registration information to the timed task thread to register a POS self-settlement task, wherein the POS self-settlement registration information comprises: a POS self-settlement timestamp; wherein the registration information includes: the name of the timing task and a trigger event of the timing task; the POS self-service settlement service refers to the task requirement that the POS settlement service is triggered at a specific time every day.
6. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which, when executed by one or more processors, implements the steps of the method according to any one of claims 1 to 4.
CN201811054877.3A 2018-09-11 2018-09-11 Timing task execution method, terminal device and storage medium Active CN109445954B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811054877.3A CN109445954B (en) 2018-09-11 2018-09-11 Timing task execution method, terminal device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811054877.3A CN109445954B (en) 2018-09-11 2018-09-11 Timing task execution method, terminal device and storage medium

Publications (2)

Publication Number Publication Date
CN109445954A CN109445954A (en) 2019-03-08
CN109445954B true CN109445954B (en) 2020-11-24

Family

ID=65532563

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811054877.3A Active CN109445954B (en) 2018-09-11 2018-09-11 Timing task execution method, terminal device and storage medium

Country Status (1)

Country Link
CN (1) CN109445954B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110197367B (en) * 2019-05-31 2021-12-21 四川长虹电器股份有限公司 Large data volume automatic settlement method based on E-commerce platform
CN111143053A (en) * 2019-11-15 2020-05-12 杭州涂鸦信息技术有限公司 Scheduling method of timing task, server and storage device
CN114691343B (en) * 2022-06-02 2022-08-26 深圳依时货拉拉科技有限公司 Polling task execution method and device, computer equipment and readable storage medium
CN117437728B (en) * 2023-12-21 2024-03-01 飞天诚信科技股份有限公司 Method and device for realizing POS (point of sale) equipment work

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104572284B (en) * 2015-01-08 2019-03-15 游道易(北京)科技有限公司 Task realization device and method and application
CN106302565B (en) * 2015-05-12 2020-11-24 浙江格林蓝德信息技术有限公司 Scheduling method and system of service server
CN104834506B (en) * 2015-05-15 2017-08-01 北京北信源软件股份有限公司 A kind of method of use multiple threads service application
CN107766129B (en) * 2016-08-17 2021-04-16 北京金山云网络技术有限公司 Task processing method, device and system
CN107038645B (en) * 2016-12-21 2021-04-23 创新先进技术有限公司 Service processing method, device and system and server

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"网络视频监控系统虚拟数据网关设计";沈翼洲;《万方》;20151102;论文正文第3、4章 *
"自动售票机软件的设计与实现";崔鹏巍;《万方》;20121231;论文正文第3章 *

Also Published As

Publication number Publication date
CN109445954A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109445954B (en) Timing task execution method, terminal device and storage medium
CN108228814B (en) Data synchronization method and device
CN111026367B (en) Micro-service arrangement method, device, terminal equipment and storage medium
CN109145590B (en) Function hook detection method, detection equipment and computer readable medium
CN108446171B (en) Electronic device, distributed system execution task allocation method and storage medium
CN105068865A (en) Task scheduling method and apparatus
US11853792B2 (en) Baseline monitoring method and apparatus, readable medium, and electronic device
CN110633977A (en) Payment exception processing method and device and terminal equipment
CN112733206A (en) Resource allocation method, device, server and medium
CN110933698A (en) Monitoring management method, device and equipment for Internet of things card
CN108415758B (en) Distributed transaction coordination method and device
CN111459629A (en) Azkaban-based project operation method and device and terminal equipment
CN109561134B (en) Electronic device, distributed cluster service distribution method and storage medium
CN109189598B (en) Interrupt positioning method, processor and terminal equipment
CN114564294A (en) Intelligent service arranging method and device, computer equipment and storage medium
CN113515369A (en) Data processing method, system, terminal and storage medium
CN112131188A (en) Batch file distribution processing method and device
CN108021597B (en) Parallel counter, server and counting method
CN115599484A (en) Screen capturing method, screen capturing device, screen capturing equipment and computer storage medium
CN110704201A (en) Multimedia data sharing method and terminal equipment
CN111078449B (en) Information processing method, information processing device and terminal equipment
CN114637651A (en) Memory frame rate detection method and device, computer equipment and storage medium
US20120317586A1 (en) Methods of reference counting across multiple processes
CN110874277B (en) Electronic red packet processing method, electronic red packet processing device and mobile terminal
CN112667338A (en) Business line display control method and device, electronic equipment and storage medium

Legal Events

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