CN109445954A - A kind of execution method, terminal device and the storage medium of timed task - Google Patents
A kind of execution method, terminal device and the storage medium of timed task Download PDFInfo
- Publication number
- CN109445954A CN109445954A CN201811054877.3A CN201811054877A CN109445954A CN 109445954 A CN109445954 A CN 109445954A CN 201811054877 A CN201811054877 A CN 201811054877A CN 109445954 A CN109445954 A CN 109445954A
- Authority
- CN
- China
- Prior art keywords
- timed task
- thread
- task
- timed
- matched
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
- G06F9/548—Object oriented; Remote method invocation [RMI]
-
- G—PHYSICS
- G07—CHECKING-DEVICES
- G07G—REGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
- G07G1/00—Cash registers
- G07G1/12—Cash registers electronically operated
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Stored Programmes (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application is suitable for multi-thread technical field, provide a kind of execution method of timed task, terminal device and computer readable storage medium, the described method includes: creating timed task thread except JavaScript main thread, and timed task is registered in the timed task thread, the registered timed task of poll in the timed task thread, obtain matched timed task, after obtaining matched timed task, scheduling information corresponding with matched timed task is sent to the main thread, the main thread is according to the scheduling message listened to, execute timed task corresponding with the scheduling message, while executing main business in the POS application based on WEB technology by the application, timed task can also be executed.
Description
Technical field
The application belongs to execution method, terminal device and the meter of multi-thread technical field more particularly to a kind of timed task
Calculation machine readable storage medium storing program for executing.
Background technique
Point-of-sale terminal (point of sale, POS) is a kind of multi-functional terminal end, it is mounted on the contributing quotient of credit card
It family and accepts in site and is unified into network with computer, can be achieved with electronic funds and transfer accounts automatically, it, which has, supports consumption, pre-granted
Power, inquiry into balance and the functions such as transfer accounts, use safely, quickly, reliably.
Currently, POS application is based on WEB technology more, and programming language used in WEB technology is JavaScript,
The characteristics of JavaScript language is: single thread executes program, is unable to satisfy while executing main business, and it is certain fixed to execute
When task.
Summary of the invention
In view of this, execution method, terminal device and computer that the embodiment of the present application provides a kind of timed task can
Storage medium is read, to solve that timing can not be executed while executing main business in the POS application currently based on WEB technology
The problem of task.
The first aspect of the embodiment of the present application provides a kind of execution method of timed task, comprising:
Timed task thread is created except JavaScript main thread, and timing is registered in the timed task thread
Task;
The registered timed task of poll, obtains matched timed task in the timed task thread;
After obtaining matched timed task, Xiang Suoshu main thread sends scheduling letter corresponding with matched timed task
Breath;
The main thread executes timed task corresponding with the scheduling message according to the scheduling message listened to.
The second aspect of the embodiment of the present application provides a kind of terminal device, comprising:
Registering unit, for creating timed task thread except JavaScript main thread, and in the timed task
Timed task is registered in thread;
Poll units obtain matched timing for the registered timed task of poll in the timed task thread
Task;
Scheduling information transmission unit, for after obtaining matched timed task, Xiang Suoshu main thread send with it is matched
The corresponding scheduling information of timed task;
Execution unit executes corresponding with the scheduling message for the main thread according to the scheduling message listened to
Timed task.
The third aspect of the embodiment of the present application provides a kind of terminal device, including memory, processor and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
The step of realizing the method that the embodiment of the present application first aspect provides.
The fourth aspect of the embodiment of the present application provides a kind of computer readable storage medium, the computer-readable storage
Media storage has computer program, and the computer program realizes the embodiment of the present application when being executed by one or more processors
On the one hand the step of the method provided.
5th aspect of the embodiment of the present application provides a kind of computer program product, and the computer program product includes
Computer program, the computer program realize that the embodiment of the present application first aspect provides when being executed by one or more processors
The method the step of.
The embodiment of the present application provides a kind of execution method of timed task, by except JavaScript main thread
Timed task thread is created, and registers timed task in the timed task thread, the poll in the timed task thread
Registered timed task obtains matched timed task, after obtaining matched timed task, Xiang Suoshu main thread send with
The corresponding scheduling information of matched timed task, the main thread execute and disappear with described dispatch according to the scheduling message listened to
Cease corresponding timed task.Since the relevant program of timed task operates in timed task thread, to the main journey in main thread
Sequence code does not block, loose coupling, easily integrates;By being arranged timed task in timed task thread, single thread fortune is got rid of
The constraint of row environment is realized the triggering scheduling mechanism to timed task with multithreading message synchronization, and can be appointed simultaneously in timing
Multiple timed tasks are run in business thread, allow for executing main industry in the POS application based on WEB technology in this way
While business, additionally it is possible to execute timed task.
Detailed description of the invention
It in order to more clearly explain the technical solutions in the embodiments of the present application, below will be to embodiment or description of the prior art
Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only some of the application
Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these
Attached drawing obtains other attached drawings.
Fig. 1 is a kind of framework of the execution method of timed task provided by the embodiments of the present application, main thread and fixed in framework
When mission thread flow diagram;
Fig. 2 is a kind of flow diagram of the execution method of timed task provided by the embodiments of the present application;
Fig. 3 is the flow diagram of the execution method of another timed task provided by the embodiments of the present application;
Fig. 4 is a kind of schematic block diagram of terminal device provided by the embodiments of the present application;
Fig. 5 is the schematic block diagram of another terminal device provided by the embodiments of the present application.
Specific embodiment
In being described below, for illustration and not for limitation, the tool of such as particular system structure, technology etc is proposed
Body details, so as to provide a thorough understanding of the present application embodiment.However, it will be clear to one skilled in the art that there is no these specific
The application also may be implemented in the other embodiments of details.In other situations, it omits to well-known system, device, electricity
The detailed description of road and method, so as not to obscure the description of the present application with unnecessary details.
It should be appreciated that ought use in this specification and in the appended claims, term " includes " instruction is described special
Sign, entirety, step, operation, the presence of element and/or component, but be not precluded one or more of the other feature, entirety, step,
Operation, the presence or addition of element, component and/or its set.
It is also understood that mesh of the term used in this present specification merely for the sake of description specific embodiment
And be not intended to limit the application.As present specification and it is used in the attached claims, unless on
Other situations are hereafter clearly indicated, otherwise " one " of singular, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in present specification and the appended claims is
Refer to any combination and all possible combinations of one or more of associated item listed, and including these combinations.
As used in this specification and in the appended claims, term " if " can be according to context quilt
Be construed to " when ... " or " once " or " in response to determination " or " in response to detecting ".Similarly, phrase " if it is determined that " or
" if detecting [described condition or event] " can be interpreted to mean according to context " once it is determined that " or " in response to true
It is fixed " or " once detecting [described condition or event] " or " in response to detecting [described condition or event] ".
In order to illustrate technical solution described herein, illustrate the architecture diagram of the embodiment of the present application first.As shown in Figure 1,
For the architecture diagram of the execution method of timed task provided by the embodiments of the present application, timed task provided by the embodiments of the present application is held
Row method needs create independently operated Web Workers thread context except JavaScript main thread, mention in browser
The interface for having supplied creation Web Workers thread object, by the Web Workers thread except JavaScript main thread
It is named as timed task thread.It also describes main thread in Fig. 1 and timed task thread respectively corresponds the process of respective side and shows
It is intended to.JavaScript main thread side can create timed task thread object and start, and can also register timed task, so
And timed task operates in timed task thread, and timestamp and the consistent timing of current time are polled in timed task thread
After task, scheduling message is sent to main thread, main thread listens to the scheduling message of timed task, executes relevant timing and appoints
Business.
One section of timer-triggered scheduler JavaScript program can be run in timed task thread.The program can be POS industry
Automatic-settlement in business, timing the punching tasks such as just.Certainly, timed task operates in timed task thread, in main thread
Main program code is not blocked, loose coupling, is easily integrated.Moreover, being got rid of by being arranged timed task in timed task thread
The constraint of single thread running environment realizes the triggering scheduling mechanism to timed task with multithreading message synchronization, for example, timing is appointed
Thread be engaged in when monitoring the timed task to be executed, sends scheduling information to main thread, main thread monitors scheduling information, holds
Row timed task relevant to scheduling information, in this way, timed task thread can support multiple timed tasks simultaneously.Certainly, it is
Multi-thread mechanism is more improved, timed task thread can provide multiple interfaces, appoint for registering timed task, updating timing
Information, closing or deletion timed task of business etc..The following is a description of specific embodiments.
Fig. 2 is a kind of implementation process schematic diagram of the execution method of timed task provided by the embodiments of the present application, as schemed institute
Show that this method may comprise steps of:
Step S201 creates timed task thread except JavaScript main thread, and in the timed task thread
Middle registration timed task.
In the embodiment of the present application, appoint in order to which some timings can also be executed except the main program task of operation
Business needs to create timed task thread except JavaScript main thread, and creation Web Workers line is provided in browser
The interface of journey object can create independently operated Web Workers thread context based on this interface except main thread.
As the another embodiment of the application, timed task thread packet is created except JavaScript main thread described
It includes:
Web Workers based on browser creates timed task thread object, and passes through the timed task thread pair
As starting timed task thread.
In the embodiment of the present application, it after creating timed task thread object, needs through the timed task line
Journey object starts timed task thread.After starting timed task thread, it is also necessary to be arranged at least in timed task thread
One timed task.Therefore, the function of timed task registration is provided in timed task thread, in order to preferably to having registered
Timed task be managed, additionally provide timed task update, timed task close or delete function.Correspondingly, also
It needs to provide interface, above-mentioned function is realized by the interface of offer.
As another embodiment of the application, the timed task of registering in the timed task thread includes:
The registration interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send registration letter
Breath, to register timed task, the registration information includes: the title of timed task and the trigger event of timed task.
In the timed task thread after registration timed task, further includes:
The more new interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread, which is sent, updates letter
Breath, to update the trigger event of timed task corresponding with the more new information;
The down interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread, which is sent, closes letter
Breath, to close timed task corresponding with the closing information.
In the embodiment of the present application, different interfaces can be provided for different functions, is then based on different interfaces
Realize different functions.When registering timed task, the title of timed task and the trigger event of timed task can be sent
Timed task thread is given, to register timed task in timed task thread.Similarly, when updating timed task, needing will be to
The trigger event of the timed task of update is sent to timed task thread.So in closing or deletion, corresponding letter is sent
Breath, can be realized the closing or deletion to specified timed task.
Step S202, the registered timed task of poll, obtains matched timed task in the timed task thread.
In the embodiment of the present application, registered timed task can be checked in turn in timed task thread to obtain
The timed task matched.The trigger event of the timed task includes the timestamp of timed task;
The registered timed task of poll in the timed task thread, obtaining matched timed task includes:
The run timing device in the timed task thread, and based on the registered timed task of timer poll
Timestamp;
If being polled to timestamp and the consistent timed task of current time, it is determined that timestamp is consistent fixed with current time
When task be matched timed task.
In the embodiment of the present application, the timer interface setInterval that can be provided using web browser, each second
Automatic detecting wheel askes the timestamp of all registered timed tasks, and compared with current time, and the timed task of time consistency is
Matched timed task.
Step S203, after obtaining matched timed task, Xiang Suoshu main thread sends corresponding with matched timed task
Scheduling information.
In the embodiment of the present application, although timed task thread can determine current pending timed task, however, needing
Want main thread that the current pending timed task of execution is gone therefore also to be counted between main thread and timed task thread
According to interaction.After timed task thread has determined the timed task of current matching, it is also necessary to be sent out by Web Workers object
Send timed task scheduling message to main thread.
Step S204, the main thread execute timing corresponding with the scheduling message according to the scheduling message listened to
Task.
In the embodiment of the present application, main thread calls timed task thread object interface by data (registration, update, closing
Or delete) it is sent to timed task thread;Meanwhile main thread also passes through the timing times that the object monitors timed task thread issues
The scheduling message of business executes timed task corresponding with the scheduling message after receiving scheduling message.
Since the relevant program of timed task operates in timed task thread, the main program code in main thread is not hindered
Plug, loose coupling, easily integration;By being arranged timed task in timed task thread, the pact of single thread running environment is got rid of
Beam is realized the triggering scheduling mechanism to timed task with multithreading message synchronization, and can be transported in timed task thread simultaneously
The multiple timed tasks of row are allowed in this way in the POS application based on WEB technology while executing main business,
Timed task can also be executed.
Fig. 3 is the implementation process schematic diagram of the execution method of another timed task provided by the embodiments of the present application, is such as schemed
It is shown to may comprise steps of:
Step S301, the Web Workers based on browser create timed task thread object, and are appointed by the timing
Business thread object starts timed task thread.
The step can refer to the associated description in embodiment illustrated in fig. 1, and details are not described herein.
Step S302, the registration interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread hair
Send POS self-help settlement registration information, to register POS self-help settlement task, the POS self-help settlement registration information include: POS from
Help the timestamp of clearing.
In the embodiment of the present application, it is illustrated by taking POS independently clearing task as an example, POS Automatic-settlement task refers to industry
Business requires to trigger POS account settlement business in specific time of the day, the registration that the timed task thread object can be called to provide
The timestamp of POS self-help settlement is sent to the timed task thread by interface, to register POS self-help settlement task.Certainly,
In practical application, other timed tasks can also be registered.May exist multiple timed tasks i.e. in timed task thread.
Step S303, the registered timed task of poll in the timed task thread, in the time of POS self-help settlement
When stabbing consistent with current time, determine that matched timed task is POS self-help settlement task.
In the embodiment of the present application, poll chartered timed task in timed task thread, for example, passing through operation
All chartered timed tasks of timer poll per second in timed task thread, during poll, if poll
Timestamp to POS self-help settlement task is consistent with current time, it is determined that POS self-help settlement task is appointed for matched timing
Business.
The scheduling information of step S304, Xiang Suoshu main thread transmission POS self-help settlement;
Step S305, the main thread execute POS self-help settlement according to the scheduling message of the POS self-help settlement listened to
Task.
In the embodiment of the present application, it is desired nonetheless to which main thread executes POS self-help settlement task, therefore, in timed task line
Matched timed task has been determined in journey after POS self-help settlement task, to need to send POS self-help settlement to the main thread
Scheduling information.And after main thread listens to the scheduling message of POS self-help settlement, execute POS self-help settlement task.
How the embodiment of the present application is illustrated by provided by the embodiments of the present application fixed by taking POS self-help settlement task as an example
When task execution method make the POS based on WEB technology apply in while executing main business, additionally it is possible to execute timing
Task, in practical application, the timed task run in timed task thread can also be other timed tasks.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present application constitutes any limit
It is fixed.
Fig. 4 is that the schematic block diagram for the terminal device that one embodiment of the application provides only is shown and this Shen for ease of description
It please the relevant part of embodiment.
The terminal device 4 can be the software unit being connected on the terminal devices such as existing POS machine, computer, hardware
Unit or the unit of soft or hard combination, are also possible to the terminal devices such as independent POS machine, computer.
The terminal device 4 includes:
Registering unit 41 is appointed for creating timed task thread except JavaScript main thread, and in the timing
Timed task is registered in business thread;
Poll units 42, for the registered timed task of poll in the timed task thread, it is matched fixed to obtain
When task;
Scheduling information transmission unit 43, for after obtaining matched timed task, Xiang Suoshu main thread to send and matches
The corresponding scheduling information of timed task;
Execution unit 44 executes corresponding with the scheduling message for the main thread according to the scheduling message listened to
Timed task.
As another embodiment of the application, the registering unit 41 is also used to:
Web Workers based on browser creates timed task thread object, and passes through the timed task thread pair
As starting timed task thread.
As another embodiment of the application, the registering unit 41 is also used to:
The registration interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send registration letter
Breath, to register timed task, the registration information includes: the title of timed task and the trigger event of timed task.
As another embodiment of the application, the terminal device 4 further include:
Updating unit 45, the more new interface for calling the timed task thread object to provide, Xiang Suoshu timed task
Thread sends more new information, to update the trigger event of timed task corresponding with the more new information;
Closing unit 46, the down interface for calling the timed task thread object to provide, Xiang Suoshu timed task
Thread sends closing information, to close timed task corresponding with the closing information.
As another embodiment of the application, the trigger event of the timed task includes the timestamp of timed task;
The poll units 42 are also used to:
The run timing device in the timed task thread, and based on the registered timed task of timer poll
Timestamp;
If being polled to timestamp and the consistent timed task of current time, it is determined that timestamp is consistent fixed with current time
When task be matched timed task.
As another embodiment of the application, the registering unit 41 is also used to:
The registration interface for calling the timed task thread object to provide, it is self-service that Xiang Suoshu timed task thread sends POS
Registration information is settled accounts, to register POS self-help settlement task, the POS self-help settlement registration information includes: POS self-help settlement
Timestamp.
As another embodiment of the application, the scheduling information transmission unit 43 is also used to:
When the timestamp of POS self-help settlement is consistent with current time, Xiang Suoshu main thread sends the tune of POS self-help settlement
Spend information;
As another embodiment of the application, the execution unit 44 is also used to:
The main thread executes POS self-help settlement task according to the scheduling message of the POS self-help settlement listened to.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function
Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of the terminal device is divided into different functional unit or module, to complete
All or part of function described above.Each functional unit in embodiment, module can integrate in one processing unit,
It is also possible to each unit to physically exist alone, can also be integrated in one unit with two or more units, above-mentioned collection
At unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function
Unit, module specific name be also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above-mentioned end
The specific work process of unit in end equipment, module, can refer to corresponding processes in the foregoing method embodiment, no longer superfluous herein
It states.
Fig. 5 is the schematic block diagram for the terminal device that the another embodiment of the application provides.As shown in figure 5, the end of the embodiment
End equipment 5 can be used as the computer connected on existing terminal device, may include: one or more processors 50,
Memory 51 and it is stored in the computer program 52 that can be run in the memory 51 and on the processor 50.The place
Reason device 50 realizes the step in above-mentioned each embodiment of the method, such as step shown in FIG. 1 when executing the computer program 52
S101 to S103.Alternatively, the processor 50 is realized in above-mentioned terminal device embodiment respectively when executing the computer program 52
Module/unit function, such as the function of module 41 to 43 shown in Fig. 4.
Illustratively, the computer program 52 can be divided into one or more module/units, it is one or
Multiple module/units are stored in the memory 51, and are executed by the processor 50, to complete the application.Described one
A or multiple module/units can be the series of computation machine program instruction section that can complete specific function, which is used for
Implementation procedure of the computer program 52 in the terminal device 5 is described.For example, the computer program 52 can be divided
It is cut into registering unit, poll units, scheduling information transmission unit, execution unit.
Registering unit, for creating timed task thread except JavaScript main thread, and in the timed task
Timed task is registered in thread;
Poll units obtain matched timing for the registered timed task of poll in the timed task thread
Task;
Scheduling information transmission unit, for after obtaining matched timed task, Xiang Suoshu main thread send with it is matched
The corresponding scheduling information of timed task;
Execution unit executes corresponding with the scheduling message for the main thread according to the scheduling message listened to
Timed task.
Other modules can refer to the description in embodiment shown in Fig. 4, and details are not described herein.
The terminal device includes but are not limited to processor 50, memory 51.It will be understood by those skilled in the art that figure
5 be only an example of terminal device 5, does not constitute the restriction to terminal device 5, may include more more or less than illustrating
Component, perhaps combine certain components or different components, for example, the terminal device can also include input equipment, it is defeated
Equipment, network access equipment, bus etc. out.
The processor 50 can be central processing unit (Central Processing Unit, CPU), can also be
Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor
Deng.
The memory 51 can be the internal storage unit of the terminal device 5, for example, terminal device 5 hard disk or
Memory.The memory 51 is also possible to the External memory equipment of the terminal device 5, such as is equipped on the terminal device 5
Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card,
Flash card (Flash Card) etc..Further, the memory 51 can also both include the storage inside of the terminal device 5
Unit also includes External memory equipment.The memory 51 is for storing needed for the computer program and the terminal device
Other programs and data.The memory 51 can be also used for temporarily storing the data that has exported or will export.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment
The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
Scope of the present application.
In embodiment provided herein, it should be understood that disclosed terminal device and method can pass through it
Its mode is realized.For example, terminal device embodiment described above is only schematical, for example, the module or list
Member division, only a kind of logical function partition, there may be another division manner in actual implementation, for example, multiple units or
Component can be combined or can be integrated into another system, or some features can be ignored or not executed.Another point is shown
The mutual coupling or direct-coupling or communication connection shown or discussed can be through some interfaces, between device or unit
Coupling or communication connection are connect, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or
In use, can store in a computer readable storage medium.Based on this understanding, the application realizes above-mentioned implementation
All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program
Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on
The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program generation
Code can be source code form, object identification code form, executable file or certain intermediate forms etc..The computer-readable medium
It may include: any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic that can carry the computer program code
Dish, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described
The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice
Subtract, such as in certain jurisdictions, according to legislation and patent practice, computer-readable medium do not include be electric carrier signal and
Telecommunication signal.
Embodiment described above is only to illustrate the technical solution of the application, rather than its limitations;Although referring to aforementioned reality
Example is applied the application is described in detail, those skilled in the art should understand that: it still can be to aforementioned each
Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified
Or replacement, the spirit and scope of each embodiment technical solution of the application that it does not separate the essence of the corresponding technical solution should all
Comprising within the scope of protection of this application.
Claims (10)
1. a kind of execution method of timed task characterized by comprising
Timed task thread is created except JavaScript main thread, and registration timing is appointed in the timed task thread
Business;
The registered timed task of poll, obtains matched timed task in the timed task thread;
After obtaining matched timed task, Xiang Suoshu main thread sends scheduling information corresponding with matched timed task;
The main thread executes timed task corresponding with the scheduling message according to the scheduling message listened to.
2. the execution method of timed task as described in claim 1, which is characterized in that it is described JavaScript main thread it
Outer creation timed task thread includes:
Web Workers based on browser creates timed task thread object, and is opened by the timed task thread object
Dynamic timed task thread.
3. the execution method of timed task as described in claim 1, which is characterized in that described in the timed task thread
Registering timed task includes:
The registration interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send registration information, with
Timed task is registered, the registration information includes: the title of timed task and the trigger event of timed task.
4. the execution method of timed task as claimed in claim 3, which is characterized in that registered in the timed task thread
After timed task, further includes:
The more new interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send more new information, with
Update the trigger event of timed task corresponding with the more new information;
The down interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send closing information, with
Close timed task corresponding with the closing information.
5. the execution method of timed task as claimed in claim 3, which is characterized in that the trigger event packet of the timed task
Include the timestamp of timed task;
The registered timed task of poll in the timed task thread, obtaining matched timed task includes:
The run timing device in the timed task thread, and the time based on the registered timed task of timer poll
Stamp;
If being polled to timestamp and the consistent timed task of current time, it is determined that timestamp and the consistent timing of current time are appointed
Business is matched timed task.
6. the execution method of timed task as claimed in claim 5, which is characterized in that described to call the timed task thread
The registration interface that object provides, Xiang Suoshu timed task thread send registration information, include: to register timed task
The registration interface for calling the timed task thread object to provide, Xiang Suoshu timed task thread send POS self-help settlement
Registration information, to register POS self-help settlement task, the POS self-help settlement registration information includes: the time of POS self-help settlement
Stamp.
7. the execution method of timed task as claimed in claim 6, which is characterized in that described to obtain matched timed task
Afterwards, Xiang Suoshu main thread transmission scheduling information corresponding with matched timed task includes:
When the timestamp of POS self-help settlement is consistent with current time, Xiang Suoshu main thread sends the scheduling letter of POS self-help settlement
Breath;
Correspondingly, the main thread executes timed task packet corresponding with the scheduling message according to the scheduling message listened to
It includes:
The main thread executes POS self-help settlement task according to the scheduling message of the POS self-help settlement listened to.
8. a kind of terminal device characterized by comprising
Registering unit, for creating timed task thread except JavaScript main thread, and in the timed task thread
Middle registration timed task;
Poll units obtain matched timed task for the registered timed task of poll in the timed task thread;
Scheduling information transmission unit, for after obtaining matched timed task, Xiang Suoshu main thread to be sent and matched timing
The corresponding scheduling information of task;
Execution unit executes timing corresponding with the scheduling message for the main thread according to the scheduling message listened to
Task.
9. a kind of terminal device, including memory, processor and storage are in the memory and can be on the processor
The computer program of operation, which is characterized in that the processor realizes such as claim 1 to 7 when executing the computer program
The step of any one the method.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has computer journey
Sequence realizes the step such as any one of claim 1 to 7 the method when the computer program is executed by one or more processors
Suddenly.
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 true CN109445954A (en) | 2019-03-08 |
CN109445954B 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) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110197367A (en) * | 2019-05-31 | 2019-09-03 | 四川长虹电器股份有限公司 | Big data quantity automatic settlement method based on electric business platform |
CN111143053A (en) * | 2019-11-15 | 2020-05-12 | 杭州涂鸦信息技术有限公司 | Scheduling method of timing task, server and storage device |
CN114691343A (en) * | 2022-06-02 | 2022-07-01 | 深圳依时货拉拉科技有限公司 | Polling task execution method and device, computer equipment and readable storage medium |
CN117437728A (en) * | 2023-12-21 | 2024-01-23 | 飞天诚信科技股份有限公司 | Method and device for realizing POS (point of sale) equipment work |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104572284A (en) * | 2015-01-08 | 2015-04-29 | 盟游(北京)科技有限公司 | Task implementation device and method and application |
CN104834506A (en) * | 2015-05-15 | 2015-08-12 | 北京北信源软件股份有限公司 | Method for processing business application through multiple threads |
CN106302565A (en) * | 2015-05-12 | 2017-01-04 | 浙江格林蓝德信息技术有限公司 | The dispatching method of service server and system |
CN107038645A (en) * | 2016-12-21 | 2017-08-11 | 阿里巴巴集团控股有限公司 | Method for processing business, apparatus and system and server |
CN107766129A (en) * | 2016-08-17 | 2018-03-06 | 北京金山云网络技术有限公司 | A kind of task processing method, apparatus and system |
-
2018
- 2018-09-11 CN CN201811054877.3A patent/CN109445954B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104572284A (en) * | 2015-01-08 | 2015-04-29 | 盟游(北京)科技有限公司 | Task implementation device and method and application |
CN106302565A (en) * | 2015-05-12 | 2017-01-04 | 浙江格林蓝德信息技术有限公司 | The dispatching method of service server and system |
CN104834506A (en) * | 2015-05-15 | 2015-08-12 | 北京北信源软件股份有限公司 | Method for processing business application through multiple threads |
CN107766129A (en) * | 2016-08-17 | 2018-03-06 | 北京金山云网络技术有限公司 | A kind of task processing method, apparatus and system |
CN107038645A (en) * | 2016-12-21 | 2017-08-11 | 阿里巴巴集团控股有限公司 | Method for processing business, apparatus and system and server |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110197367A (en) * | 2019-05-31 | 2019-09-03 | 四川长虹电器股份有限公司 | Big data quantity automatic settlement method based on electric business platform |
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 |
CN114691343A (en) * | 2022-06-02 | 2022-07-01 | 深圳依时货拉拉科技有限公司 | Polling task execution method and device, computer equipment and readable storage medium |
CN117437728A (en) * | 2023-12-21 | 2024-01-23 | 飞天诚信科技股份有限公司 | Method and device for realizing POS (point of sale) equipment work |
CN117437728B (en) * | 2023-12-21 | 2024-03-01 | 飞天诚信科技股份有限公司 | Method and device for realizing POS (point of sale) equipment work |
Also Published As
Publication number | Publication date |
---|---|
CN109445954B (en) | 2020-11-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109445954A (en) | A kind of execution method, terminal device and the storage medium of timed task | |
CN106020948B (en) | A kind of process dispatch method and device | |
CN109842565A (en) | Interface current-limiting method, device, electronic equipment and storage medium | |
CN108255589A (en) | Method for scheduling task and server | |
CN109901920A (en) | Method for scheduling task and device, electric terminal | |
CN107729139A (en) | A kind of method and apparatus for concurrently obtaining resource | |
CN109918141A (en) | Thread execution method, device, terminal and storage medium | |
CN110069353A (en) | Business asynchronous processing method and device | |
CN110049113A (en) | Service message processing method and device | |
CN105068865A (en) | Task scheduling method and apparatus | |
CN110245029A (en) | A kind of data processing method, device, storage medium and server | |
CN110322127A (en) | A kind of project scheduling method, equipment, server and computer readable storage medium | |
CN106791068A (en) | The based reminding method and terminal of a kind of backlog | |
CN111506430A (en) | Method and device for data processing under multitasking and electronic equipment | |
CN109343972A (en) | Task processing method and terminal device | |
CN105931112A (en) | Cross-border transaction liquidation method and system | |
CN109871229A (en) | Management method, device, storage medium and the terminal device of code text | |
CN114461355A (en) | Heterogeneous computing cluster unified management method and device, electronic equipment and storage medium | |
CN111400062A (en) | Information notification method, device, system and computer readable storage medium | |
CN108830596A (en) | The acquisition device and terminal device of a kind of acquisition methods of information, information | |
CN110389976A (en) | A kind of dispatching method and device of multi-interface data | |
CN109388482A (en) | Dispatching method, device and the storage medium of task | |
CN109783072A (en) | Method for processing business, device, terminal device and computer readable storage medium | |
CN108021597B (en) | Parallel counter, server and counting method | |
CN109213589A (en) | A kind of method and device of Message Processing |
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 |