Information of freight source update method, system, equipment and storage medium based on time wheel
Technical field
The present invention relates to logistics technology, specifically, be related to it is a kind of based on the time wheel information of freight source update method,
System, equipment and storage medium.
Background technique
After source of goods publication, until needing periodically to automatically update the source of goods, enabling users to check at any time before source of goods failure
To the newest effective source of goods.
Traditional scheme can add in systems a timed task for each source of goods, and timed task is automatic to object time point
Triggering is to update the source of goods.This scheme can generate a large amount of timed task in systems, timed task for resource consumption compared with
Greatly, system can not support a large amount of timed task while carry out.
It should be noted that information is only used for reinforcing the reason to background of the invention disclosed in above-mentioned background technology part
Solution, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
In view of this, the present invention provide it is a kind of based on the time wheel information of freight source update method, system, equipment and storage be situated between
Matter solves the source of goods in the prior art and updates to occupy a large amount of system resources, and system can not support the progress simultaneously of a large amount of timed tasks
Problem.
According to an aspect of the present invention, a kind of information of freight source update method based on time wheel is provided, comprising: obtain goods
The update cycle of source information and each information of freight source;Multistage time wheel is set, and every grade of time wheel is according to respective unit time value
It is divided into end to end cell queue, the unit time value of rear class time wheel is equal to the total time value of wheel of adjacent prime time;
For every grade of one cycle index of time wheel setting, the cycle index of time wheels at different levels moves forward one every respective unit time value
A cell;By the update cycle of information of freight source and matched unit time value modulus, according to modulus result by information of freight source
Update event is added to the cell that self-loopa pointer currently points in corresponding time wheel and plays the list that sequence is equal to its modulus result
In first lattice;And the update event in the cell that currently points to of the cycle index of executable unit's time value the smallest time wheel.
Preferably, above-mentioned information of freight source update method further include: refer to the circulation of the smallest time wheel of unit time value
The update event in cell that needle currently points to is added to the cell that self-loopa pointer currently points in corresponding time wheel
Next cell plays sequence and is equal in the cell of its modulus result.
Preferably, above-mentioned information of freight source update method further include: the prime time cycle index of wheel traverses its cell
After queue, the cycle index of adjacent rear class time wheel moves forward a cell.
Preferably, above-mentioned information of freight source update method further include: currently point to the cycle index that the rear class time takes turns
Update event in cell migrates in each unit lattice taken turns to the adjacent prime time, until migrating the smallest to unit time value
In each unit lattice of time wheel.
Preferably, in above-mentioned information of freight source update method, unit that the cycle index that the rear class time takes turns is currently pointed to
As update event to be migrated, update event to be migrated migrates each list taken turns to the adjacent prime time for update event in lattice
Step in first lattice includes: the accumulated time value of cell where the update cycle of update event to be migrated is subtracted it, is obtained
To remaining time value;By the unit time value modulus of the remaining time value and wheel of adjacent prime time;And according to modulus knot
Update event to be migrated is migrated the cell that self-loopa pointer currently points into wheel of adjacent prime time and plays sequence etc. by fruit
In in the cell of its modulus result.
Preferably, in above-mentioned information of freight source update method, time wheel where the accumulated time value of cell is equal to it
The product of unit time value and its sequence from head of the queue cell.
Preferably, in above-mentioned information of freight source update method, by the update cycle of information of freight source and matched unit time
Before being worth modulus further include: obtain the maximum time unit of the update cycle of information of freight source;By the unit with same time unit
The unit time value that time value matches as the update cycle with information of freight source.
Preferably, in above-mentioned information of freight source update method, the corresponding time wheel is the update cycle with information of freight source
The wheel of time corresponding to the unit time value to match.
Preferably, in above-mentioned information of freight source update method, the multistage time wheel includes the time list of unit time value
The wheel of adjacent rear class time that position is the prime time wheel of minute and the chronomere of unit time value is several hours.
Preferably, in above-mentioned information of freight source update method, the unit time value of prime time wheel is 1 minute, after adjacent
The unit time value of grade time wheel is 1 hour.
According to another aspect of the present invention, a kind of information of freight source more new system based on time wheel is provided, comprising: obtain
Module, for obtaining the update cycle of information of freight source and each information of freight source;Time takes turns setup module, for the multistage time to be arranged
Wheel, wheel of every grade of time are divided into end to end cell queue according to respective unit time value, when the unit of rear class time wheel
Between value be equal to the adjacent prime time wheel total time value;Pointer setup module, for a cycle index to be arranged for every grade of time wheel,
The cycle index of time wheels at different levels moves forward a cell every respective unit time value;Original allocation module, is used for
By the update cycle of information of freight source and matched unit time value modulus, the update event of information of freight source is added according to modulus result
It adds to the cell that self-loopa pointer currently points in corresponding time wheel and plays sequence equal in the cell of its modulus result;And
Execution module, the update thing in cell that the cycle index for the smallest time wheel of executable unit's time value currently points to
Part.
Preferably, above-mentioned information of freight source more new system further include: reallocation module, for unit time value is the smallest
It is current to be added to self-loopa pointer in corresponding time wheel for the update event in cell that the cycle index of time wheel currently points to
The next cell of the cell of direction plays sequence and is equal in the cell of its modulus result.
Preferably, above-mentioned information of freight source more new system further include: transferring module, for referring to when the circulation of rear class time wheel
When needle moves forward, the update event in cell that the cycle index that the rear class time takes turns currently points to is migrated to adjacent prime
In each unit lattice of time wheel, until migrating to each unit lattice of the smallest time wheel of unit time value.
According to an aspect of the present invention, a kind of information of freight source more new equipment based on time wheel, including processor are provided
And memory, memory are configured to execute via the executable instruction is executed for storing executable instruction, processor
The step of information of freight source update method based on time wheel stated.
According to an aspect of the present invention, a kind of computer readable storage medium is provided, computer program is stored thereon with,
The computer program realizes the step of above-mentioned information of freight source update method based on time wheel when being executed by processor.
The beneficial effect of the present invention compared with prior art is:
The present invention is by being arranged multistage time wheel, the update for the information of freight source that every grade of wheel storage update cycle time matches
Event is combined by internal layer list time wheel, outer layer recombination time wheel, can be stored largely using only a small amount of memory space
The update event of information of freight source.What the cycle index that execute only needs the inspection innermost layer time to take turns every time when update event currently pointed to
Cell is equivalent to and is divided the more new task of a large amount of information of freight source, only handles necessary partial task every time, reduces
Unnecessary calculating, saves system resource.
It should be understood that above general description and following detailed description be only it is exemplary and explanatory, not
It can the limitation present invention.
Detailed description of the invention
The drawings herein are incorporated into the specification and forms part of this specification, and shows and meets implementation of the invention
Example, and be used to explain the principle of the present invention together with specification.It should be evident that the accompanying drawings in the following description is only the present invention
Some embodiments for those of ordinary skill in the art without creative efforts, can also basis
These attached drawings obtain other attached drawings.
Fig. 1 shows a kind of step schematic diagram of the information of freight source update method based on time wheel in the embodiment of the present invention;
Fig. 2 shows a kind of multistage time wheels being arranged in the embodiment of the present invention;
Fig. 3 shows the multistage time wheel of another being arranged in the embodiment of the present invention;
Fig. 4 show in the embodiment of the present invention by update event from the rear class time wheel migrate to the adjacent prime time take turns the step of
Schematic diagram;
Fig. 5 shows the multistage time wheel of another being arranged in the embodiment of the present invention;
Fig. 6 shows a kind of module diagram of the information of freight source more new system based on time wheel in the embodiment of the present invention;
Fig. 7 shows a kind of schematic diagram of the information of freight source more new equipment based on time wheel in the embodiment of the present invention;
Fig. 8 shows a kind of schematic diagram of computer readable storage medium in the embodiment of the present invention.
Specific embodiment
Example embodiment is described more fully with reference to the drawings.However, example embodiment can be with a variety of shapes
Formula is implemented, and is not understood as limited to embodiment set forth herein.On the contrary, thesing embodiments are provided so that the present invention will
Fully and completely, and by the design of example embodiment comprehensively it is communicated to those skilled in the art.It is identical attached in figure
Icon note indicates same or similar structure, thus will omit repetition thereof.
Referring to figs. 1 and 2, in the present embodiment based on the time wheel information of freight source update method include but is not limited to
Lower step:
S10, the update cycle for obtaining information of freight source and each information of freight source.
Wherein, each information of freight source has the respective update cycle, such as some information of freight source need often to update every few seconds
Once, some information of freight source need to update every few minutes once, some information of freight source update primary every a few houres.
S20, multistage time wheel is set, every grade of time wheel is divided into end to end cell according to respective unit time value
The unit time value of queue, rear class time wheel is equal to the total time value of wheel of adjacent prime time.
Wherein, every grade of time wheel is divided into end to end cell queue according to respective unit time value, also will be every
Grade time wheel is divided equally according to respective unit time value, forms end to end cell queue, the time value of each cell
Equal to the unit time value of time wheel where it.The unit time value of rear class time wheel is equal to the total time of wheel of adjacent prime time
Value namely rear class time wheel are recombination time wheel for prime time wheel, and rear class time each cell of wheel includes
The time value of all cells of adjacent prime time wheel.
It is taken turns referring to the N grades of time shown in Fig. 2.The smallest time wheel of unit time value (the innermost layer time wheel illustrated) A
It is divided into end to end cell queue { A according to its unit time value1,A2,…,Aa, a can be arbitrary integer, such as 5,
10,20,30,60 etc..The time value that time takes turns each cell in A is equal to its unit time value.Time wheel B is time wheel A
The adjacent rear class time wheel, the time wheel B be divided into end to end cell queue { B according to its unit time value1,B2,…,Bb,
B can be arbitrary integer, such as 5,10,20,30,60 etc..When the time value that time takes turns each cell in B is equal to its unit
Between be worth, and be equal to the time wheel A total time value.And so on, it may include multistage time wheel, every grade of time wheel outside time wheel B
It is divided into several end to end cells according to respective unit time value, the time value of each cell is equal to its unit
Time value, and the unit time value of rear class time wheel is equal to the total time value of wheel of adjacent prime time.It is taken turns until the outermost layer time
N, the time, wheel N was also divided into end to end cell queue { N according to its unit time value1,N2,…,Nn, n can be any whole
Number, such as 5,10,20,30,60 etc..The time value that time takes turns each cell in N is equal to its unit time value, and is equal to phase
The total time value of adjacent prime time wheel.Wherein, alphabetical A, B ... N is only used to distinguish time wheel not at the same level, not to the multistage time
The series of wheel generates limitation.
In one embodiment, multistage time wheel is to take turns the three-level time, and wherein the unit time value of time wheel A is minimum,
Chronomere is, for example, the second.The chronomere that time takes turns the unit time value of B is, for example, minute.The unit time value of time wheel N
Maximum, chronomere are, for example, hour.
More specifically, in one embodiment, the unit time value of time wheel A can be 1 second, 2 seconds, 5 seconds, 10 seconds etc.
It is 60 seconds Deng, total time value;The unit time value of time wheel B is the total time value of time wheel A, and unit time value is 1 point
Clock, the total time value that the time takes turns B is 60 minutes;The unit time value of time wheel N is the total time value of time wheel B, when unit
Between value be 1 hour, total time value can be optionally arranged, such as on the basis of day, be set as 24 hours.
In above-described embodiment, every grade of time wheel is set and is divided into end to end cell team according to respective unit time value
Column, and the unit time value of rear class time wheel is equal to the beneficial effect of the total time value of wheel of adjacent prime time: so that multistage
The time cell queue of wheel can combine the memory space to form corresponding different time value, different more convenient for subsequent match storage
The update event in new period.
S30, one cycle index is set for every grade of time wheel, the cycle index of times wheels at different levels is every the respective unit time
Value moves forward a cell.
Referring to shown in Fig. 2, the time takes turns A and is equipped with cycle index PA, the time, wheel B was equipped with cycle index PB, wheel N was equipped with and followed the time
Fourth finger needle PN.Taking turns the unit time value of A when the time is 5 seconds, then cycle index PAEvery one cell of forward movement in 5 seconds, such as
From the cell A of diagram1It is moved to cell A2, and constantly moved forward according to its unit time value, when being moved to cell Aa
Afterwards, due to cell queue { A1,A2,…,AaEnd to end, every 5 seconds cycle index PAIt is moved again to cell A1, so follow
Ring rotation.Similarly, when the unit time value of time wheel B is 1 minute, then cycle index PBEvery one list of forward movement in 1 minute
First lattice, such as the cell B from diagram1It is moved to cell B2, and continuous cycle rotation.When the time, the unit time value of wheel N is
1 hour, then cycle index PNEvery one cell of forward movement in 1 hour, such as the cell N from diagram2It is moved to cell
N2, and continuous cycle rotation.The rotation direction of cycle index is as shown in the clockwise direction that arrow is indicated in Fig. 2.
In some embodiments, the cycle index that every grade of time takes turns under original state is directed to the head of the queue of its cell queue
Cell, such as cycle index P in Fig. 2AIt is directed toward head of the queue cell A1, cycle index PBIt is directed toward head of the queue cell B1, cycle index PN
It is directed toward head of the queue cell N1It is shown.In other change case, the cycle index that every grade of time takes turns under original state can also be directed toward
Any cell in its cell queue, the cell at this time currently pointing to cycle index regard head of the queue cell as.
S40, by the update cycle of information of freight source and matched unit time value modulus, according to modulus result by information of freight source
Update event be added to the cell that self-loopa pointer currently points in corresponding time wheel and play sequence and be equal to its modulus result
In cell.
In a preferred embodiment, it is deposited from big to small after the update cycle for obtaining information of freight source according to chronomere
Storage.For example, the update cycle of information of freight source x is 30 seconds, then it is stored as 30 seconds after obtaining its update cycle;Information of freight source y is more
The new period is 30 minutes, then is stored as 30 minutes after obtaining its update cycle, is stored without minute is converted into the second;Goods
The update cycle of source information z is 30 minutes 1 hour, then is stored as 30 minutes 1 hour after obtaining its update cycle, without storing
For the forms such as 90 minutes.The update cycle of information of freight source is had the beneficial effect that using aforesaid way storage convenient for each update
Period distinguish according to chronomere (such as divide into the update cycle in hours, in minutes, in seconds), from
And it is matched in the time wheel with same time unit.Such as the update event meeting of the information of freight source of update cycle in hours
The corresponding chronomere for being added to unit time value is the update of the information of freight source of update cycle in seconds in the time wheel of hour
It is in the time wheel of second that event, which can then correspond to and be added to the chronomere of unit time value,.
Certainly, in other change case, the update cycle of information of freight source can also be stored according to unified chronomere,
Such as it is all stored as unit of minute.Method hereafter can also be used by its point in the mode of update cycle uniform units storage
It is assigned in corresponding time wheel, only step is slightly complicated, hereinafter can simply illustrate.
It further, will further include the determining and source of goods before the update cycle of information of freight source and matched unit time value modulus
The step of update cycle of information matched unit time value.It specifically includes: obtaining the update cycle of information of freight source most first
Big chronomere, the maximum time unit for such as obtaining the update cycle (30 minutes) of information of freight source y is minute;Then will have
The unit time value that the unit time value of same time unit matches as the update cycle with information of freight source.For example, according to
The time of chronomere's " minute " of the update cycle of information of freight source y, the unit time value (1 minute) of screening to time wheel B is single
Position is also minute, then the unit time unit time value of time wheel B to match as the update cycle with information of freight source y
Value.
After the determining update cycle matched unit time value with information of freight source, by the update cycle of information of freight source and this
The unit time value modulus matched.Such as by (1 point of unit time value of the update cycle (30 minutes) of information of freight source y and time wheel B
Clock) modulus, obtain modulus result 30.According to the modulus result 30, the update event of information of freight source y is added in time wheel B
Self-loopa pointer PBThe cell B currently pointed to1It plays sequence to be equal in the cell of its modulus result 30, i.e. cell B30It is interior.
According to the method for the update event of above-mentioned addition information of freight source, by the update event of all information of freight source of acquisition
With being added in the corresponding unit lattice of corresponding time wheel.Information of freight source z as escribed above, according to (1 hour 30 points of its update cycle
Clock) maximum time unit " hour ", screening to same time unit unit time value be the time take turns N unit time
Be worth (1 hour), then by the unit time value (1 hour) as with the update cycle of information of freight source z matched unit time value.Goods
Modulus result obtained by the update cycle (30 minutes 1 hour) of source information z and unit time value (1 hour) modulus is 1, then by the source of goods
The update event of information z is added to self-loopa pointer P in the corresponding time wheel N of the unit time value (1 hour)NIt currently points to
Cell N1Play the cell N that sequence is equal to the modulus result 11。
Wherein, cell N1It is interior to store the update cycle at 1 hour to 2 hours (specifically greater than 1 hour less than or equal to 2
Hour) between all information of freight source update event.Similarly, cell N2The update cycle is stored in 2 hours to 3 hours (tools
Body be greater than 2 hours be less than or equal to 3 hours) between all information of freight source update event.Cell B1Store the update cycle
The update event of all information of freight source between 1 minute to 2 minutes (be specifically greater than 1 minute and be less than or equal to 2 minutes).
The update event in cell that the cycle index of the smallest time wheel of S50, executable unit's time value currently points to.
Wherein, executing update event is to carry out asynchronous refresh operation to information of freight source.
Unit time value with above-mentioned time wheel A is 5 seconds, and the unit time value that the time takes turns B is 1 minute, and the time takes turns N
Unit time value be that when updating information of freight source, the smallest time wheel A's of executable unit's time value is followed for 1 hour
Fourth finger needle PAThe cell A currently pointed to1Middle stored update event.The cycle index of the smallest time wheel A of unit time value
PAThe cell A currently pointed to1The update event of middle storage is the update thing of a collection of information of freight source to arrive at first the update cycle
Part.Cell A is executed1In update event after, (every 5 seconds) cycle index PAIt is moved to cell A2, continue to execute cell
A2In update event.
According to the method described above, executing every time only needs the circulation of the smallest time wheel of inspection unit time value to refer to when update event
The cell that needle currently points to, is equivalent to and is divided the more new task of all information of freight source, only handles every time necessary
Partial task reduces unnecessary calculating.
Further, information of freight source update method further include: S60, refer to the circulation of the smallest time wheel of unit time value
The update event in cell that needle currently points to is added to the cell that self-loopa pointer currently points in corresponding time wheel
Next cell plays sequence and is equal to cycle index in the cell of its modulus result.
By taking the time takes turns A as an example, unit time value is minimum, is 5 seconds.The update cycle of one information of freight source w is 10 seconds.Just
When beginning to distribute, the update event of information of freight source w is added into the cell A of time wheel A2In.As cycle index PAIt is moved to unit
Lattice A2, then execution unit lattice A2In all update events (which includes the update events of information of freight source w);And synchronously,
To cell A2In all update events reallocate.By taking the update event of information of freight source w as an example, information of freight source w is more
The modulus result of the unit time value of new period and time wheel A is 2, then adds (next time) update event of information of freight source w
The self-loopa pointer P into time wheel AAThe cell A currently pointed to2Next cell A3It plays sequence and is equal to modulus result 2 (i.e.
From cell A3Rise several two cells) cell A4.Cell A2In other update events similarly reallocate.With
And as cycle index PAIt is moved to cell A4, then the update event of information of freight source w is performed again;Synchronously, by unit
Lattice A4In all update events (including original allocation is to cell A4In update event, such as the update cycle be 20 seconds more
New events;And it is redistributed to cell A4In update event, such as the update event of information of freight source w) reallocate, goods
The update event of source information w is added into self-loopa pointer PAThe cell A currently pointed to4Next cell A5Play sequence etc.
In the cell A of modulus result 26.Then as cycle index PAIt is moved to cell A6When information of freight source w update event can be another
It is secondary to be performed.And so on, cycle index PATwo cells of every movement (elapsed time value is 10 seconds), information of freight source w's
Update event is executed once namely information of freight source w updated once every 10 seconds, meets its update cycle.
According to the method described above, in the cell that the cycle index of the smallest time wheel of executable unit's time value currently points to
Update event when, synchronously (so-called synchronization is not proper while carrying out, and executes update event and reallocation
As long as completing in the smallest unit time value, guarantee does not influence the update event of next cell after cycle index movement
Execution) update event in the cell that currently points to of cycle index of unit time value the smallest time wheel is carried out
It reallocates, and cycle assignment according to this.Executing update event every time only needs the circulation of the smallest time wheel of inspection unit time value
The cell that pointer currently points to, and the update of cell that the cycle index of unit time value the smallest time wheel currently points to
Event, which is performed, to be synchronously reallocated, and guarantees the execution of each update event next time.When the smallest with unit time value
Between the cycle index taken turns constantly be moved along, each update event is constantly performed and is reallocated.During this
System only needs to handle in the cell that the cycle index that the unit time value the smallest time takes turns currently points to more in the same period
The execution and reallocation of new events, data volume to be processed is few, takes up less resources, and treatment effeciency is high.
Wherein, each cell is easily added using the update event of elongated list storage information of freight source convenient for subsequent
With deletion update event.The reallocation and hereinafter moving the update event mentioned that addition update event includes update event
It moves;It deletes update event and refers to the update event for deleting the information of freight source of failure.
In some embodiments, the update method of information of freight source further include: the cycle index of wheel traverses it when the prime time
After cell queue, the cycle index of adjacent rear class time wheel moves forward a cell.
It is taken turns referring to the three-level time shown in Fig. 3.As the cycle index P of time wheel AATraversal Unit lattice queue { A1,A2,…,
AaAfter, a lattice are moved forward again to cell A1When, the time takes turns the cycle index P of BBIt moves forward a cell and reaches list
First lattice B2.And the cycle index P according to time wheel AATraversal Unit lattice queue { A1,A2,…,AaAfterwards the time wheel B circulation refer to
Needle PBThe rule for moving forward a cell, as the cycle index P of time wheel BBTraversal Unit lattice queue { B1,B2,…,Bb}
Afterwards, a lattice are moved forward again to cell B1When, the time takes turns the cycle index P of NNA cell will be moved forward, from diagram
Cell N1It is moved to cell N2(cycle index P is indicated using dotted arrow in figureNMovement subsequently points to cell N2)。
Further, after the cycle index of rear class time wheel is mobile, the cycle index that the rear class time takes turns need to be currently pointed to
Cell in update event migrate to the adjacent prime time take turns each unit lattice, until migrate it is the smallest to unit time value
The each unit lattice of time wheel.
Referring to shown in Fig. 4, in a preferred embodiment, the cell that the cycle index that the rear class time takes turns is currently pointed to
Update event the step of migrating to the adjacent prime time each unit lattice taken turns include: S701, by update event to be migrated
Accumulated time value of cell, obtains remaining time value where update cycle subtracts it.Wherein update event to be migrated refers to
The update event for the cell that the cycle index of rear class time wheel currently points to.When the accumulated time value of cell is equal to its place
Between the unit time value taken turns and its sequence from head of the queue product.S702, by remaining time value and the adjacent prime time wheel
Unit time value modulus;S703, update event to be migrated is migrated according to modulus result and is followed certainly into wheel of adjacent prime time
The cell that fourth finger needle currently points to plays sequence and is equal in the cell of its modulus result.
With the cycle index P of the wheel B of time shown in Fig. 3BThe cell B currently pointed to2Each update to be migrated of middle storage
For event is migrated to each unit lattice of time wheel A.As cycle index PBIt is moved to cell B2When, due to cell B2
In be stored with the update cycle and be less than or equal to update event in 3 minutes greater than 2 minutes, the update cycle of each update event not phase
Deng, such as the update cycle of some update events is 15 seconds 2 minutes, the update cycle of some update events is 30 seconds 2 minutes, is had
The update cycle of a little update events is 45 seconds 2 minutes, can not be executed at the same time, therefore need to gradually be migrated to unit time value minimum
Time wheel A each unit lattice in, so that each update event is accurately carried out according to the update cycle of its own.
For example, cell B2Middle initial storage has the update event of information of freight source v, and the update cycle is 2 minutes 30
Second, need the update event by information of freight source v to migrate to the corresponding unit lattice of time wheel A.First by the update of information of freight source v
Cell B where the update cycle (30 seconds 2 minutes) of event subtracts it2Accumulated time value, cell B2Accumulated time value etc.
Unit time value (1 minute) and its sequence (cell B from head of the queue cell of time wheel B where it2In cell team
Arrange { B1,B2,…,BbIn from head of the queue cell B1The product being ordered as 2) is acted, i.e., 2 minutes, obtains remaining time value 30 seconds.It connects
By remaining time value (30 seconds) and the adjacent prime time wheel A unit time value (5 seconds) modulus, obtain modulus result be 6.Most
The update event of information of freight source v is migrated into the self-loopa pointer P into time wheel A afterwardsAThe cell A currently pointed to1Sequence is played to be equal to
The cell of its modulus result, i.e. cell A6.In this way, the update event of information of freight source v is migrated to cell A6, work as the time
Take turns the cycle index P of AAFrom the cell A currently pointed to1It rises and was moved to cell A by 30 seconds6, the update thing of information of freight source v
Part is performed, the cell B where the update event that the time being actually passed through at this time is information of freight source v is initial2Accumulation when
Between be worth (2 minutes) plus migration after cell A6Accumulated time value (30 seconds), that is, the time being actually passed through be 30 seconds 2 minutes,
The update event of information of freight source v is performed, and meets its update cycle.And synchronously, the update event of information of freight source v is divided again
Match, executes update event every its update cycle to realize.
By above-mentioned method, when one circle of cycle index traversal of the smallest time wheel of unit time value, original allocation, packet
The update event that circulation is redistributed in all cells of the smallest time wheel of unit time value is included to be executed in batches.This
The cycle index that the Shi Xianglin rear class time takes turns moves forward a lattice, the update thing of the cell currently pointed to after cycle index is mobile
Part is accordingly migrated to the respective cells of the smallest time wheel of unit time value, so that each update event is according to its update
Period is performed.And so on, whenever the cycle index forward movement of rear class time wheel, then will currently refer to after cycle index movement
To cell update event migrate to the adjacent prime time take turns, and by the adjacent prime time take turns cycle index currently point to
Cell in update event before move again, until migrating to each unit lattice of unit time value the smallest time wheel.
During migration, it is only necessary to check the update event in cell that the cycle index of times at different levels wheel currently points to, and
During executing and reallocating, it is only necessary to check the cell that the cycle index of the smallest time wheel of unit time value currently points to
Interior update event takes turns compound storage structure by the multistage time, migrates, executes, reallocates in batches, so that a small amount of unit
Lattice can store a large amount of update event, and current partial task is only handled in the same time, subtract unnecessary calculating.
The update method of the information of freight source of above-mentioned any embodiment is described below with reference to a specific embodiment.
It referring to Figure 5, is the two-stage time wheel in the present embodiment according to the setting of the update cycle of the information of freight source of acquisition, including internal layer
Time takes turns C and the outer layer time takes turns D.The unit time value that the internal layer time takes turns C is 1 minute, and cell queue is { C1,C2,…,
C60, totally 60 cells.The unit time value that the outer layer time takes turns D is 1 hour, and cell queue is { D1,D2,…,D12, altogether
12 cells.
Time wheel level setting depend on each information of freight source obtained update cycle minimum interval and
Maximum time interval.The minimum interval of the update cycle obtained in the present embodiment is 1 minute, and maximum time interval is 2 small
When, therefore two-stage time wheel is set, it is the circular list for including 60 cells, the time of each cell that the internal layer time, which takes turns C,
Value is 1 minute, and outer layer time wheel D is the circular list for including 12 cells, and the time value of each cell is 1 hour.Often
A cycle index is arranged in grade time wheel, and cycle index is directed toward the first cell of every grade of time wheel under original state.As shown
The cycle index P of time wheel CCCell C is directed toward under original state1, cycle index PCEvery 1 minute along diagram clockwise arrow
Direction moves forward a cell.The cycle index P of time wheel DDCell D is directed toward under original state1, cycle index PDEvery 1
Hour moves forward a cell along diagram clockwise arrow direction.
In the information of freight source of acquisition, including information of freight source h, update cycle are 1 minute;Information of freight source i, update cycle 2
Minute;Information of freight source j, update cycle are 45 minutes;Information of freight source k, update cycle are 30 minutes 1 hour.When original allocation, goods
The update event of source information h is distributed to the cell C of time wheel C1In;The update event of information of freight source i is distributed to time wheel C's
Cell C2In;The update event of information of freight source j is distributed to the cell C of time wheel C45In;The update event of information of freight source k point
It is assigned to the cell D of time wheel D1In.
The cycle index P of time wheel CCCurrently point to cell C1, then execution unit lattice C1The information of freight source h's of middle storage
Update event;Synchronously, the update event of information of freight source h is added to cell C2In, then cell C at this time2In include initial
The update event of the information of freight source h of update event and the reallocation of the information of freight source i of distribution.By the unit time of time wheel C
After value 1 minute, cycle index PCA lattice are moved forward, cell C is directed toward2, then execution unit lattice C2The information of freight source i of middle storage
Update event and information of freight source h update event;Synchronously, the update event of information of freight source i is added to cell C4In
And the update event of information of freight source h is added to cell C3In, then cell C at this time4In include initially allocated update event
With the update event of the information of freight source i of reallocation, cell C3In also include initially allocated update event and reallocation goods
The update event of source information h.And so on be updated event execution and circulation reallocate.
As cycle index PCIt is moved to cell C45, then execution unit lattice C45The update event of the information of freight source j of middle storage,
And reallocate to the update event of information of freight source j, from cycle index PCThe cell C currently pointed to45Next unit
Lattice C46It rises, 45 cells of number (cell queue { C1,C2,…,C60End to end, therefore recyclable rotation counts) reach list
First lattice C15, then the update event of information of freight source j is added to cell C15In, as cycle index PCIt is moved to cell next time
C15When information of freight source j update event be executed once again.
Further, as cycle index PCOne circle of rotation, Traversal Unit lattice queue { C1,C2,…,C60After be again directed to list
First lattice C1When, the time takes turns the cycle index P of DDIt moves forward a cell and reaches cell D2(dotted arrow mark is used in figure
Show cycle index PDMovement subsequently points to cell D2).Inspection unit lattice D at this time2The update event of middle storage, and accordingly migrate to
Time takes turns in the cell of C.I.e. by cell D1The update event of the information of freight source k of middle storage is migrated to the unit of time wheel C
Lattice C30In.
By above-mentioned method, the internal layer time takes turns the cycle index P of CCEvery 1 minute one lattice of advance, and triggers and currently refer to
To cell in update event execution and reallocation;The cycle index P of outer layer time wheel DDIn following for internal layer time wheel C
Fourth finger needle PCAdvance a lattice after one circle of circulation, and triggers the migration of the update event in the cell currently pointed to.Due to outer layer
The cycle index P of time wheel DDThe update event in cell currently pointed to has already been through cycle index PDThe advance time,
It migrates, centainly falls on the cell of internal layer time wheel C, in cycle index P at this timeCIt can then be triggered when proceeding to the cell
Execute update event.
It by above-mentioned method, is taken turns using the two-stage time of 60 lattice of internal layer, 12 lattice of outer layer, it is only necessary to which 60+12=72 single
The memory space of first lattice is the update event that can be reserved for 60*12=720 different update period, excellent when the time, wheel level was more
Change effect to be more obvious.Due to only needing to check the list that the cycle index of innermost layer time wheel currently points to when executing update event every time
First lattice are equivalent to and are divided all more new tasks, only handle necessary partial task every time, reduce unnecessary
It calculates, reduces resource and use.
The embodiment of the present invention also provides a kind of information of freight source more new system based on time wheel, referring to shown in Fig. 6, the source of goods
Information update system 6 includes but is not limited to lower module:
Module 601 is obtained, for obtaining the update cycle of information of freight source and each information of freight source.
In some embodiments, the step S10 that module 601 is used to execute above-mentioned any embodiment is obtained.
Time takes turns setup module 602, and for multistage time wheel to be arranged, every grade of time wheel is according to respective unit time value point
At end to end cell queue, the unit time value of rear class time wheel is equal to the total time value of wheel of adjacent prime time.
In some embodiments, time wheel setup module 602 is used to execute the step S20 of above-mentioned any embodiment.
Pointer setup module 603, for for every grade of one cycle index of time wheel setting, the cycle index that the times at different levels take turns to be every
A cell is moved forward every respective unit time value.
In some embodiments, pointer setup module 603 is used to execute the step S30 of above-mentioned any embodiment.
Original allocation module 604, for by the update cycle of information of freight source and matched unit time value modulus, according to asking
The update event of information of freight source is added to the cell that self-loopa pointer currently points in corresponding time wheel and plays sequence by mould result
In cell equal to its modulus result.
In some embodiments, original allocation module 604 is used to execute the step S40 of above-mentioned any embodiment.
Execution module 605, the cell that the cycle index for the smallest time wheel of executable unit's time value currently points to
Interior update event.
In some embodiments, execution module 605 is used to execute the step S50 of above-mentioned any embodiment.
Further, in a preferred embodiment, information of freight source more new system further include:
Reallocation module 606, the cell for currently pointing to the cycle index of the smallest time wheel of unit time value
Interior update event, the next cell for being added to the cell that self-loopa pointer currently points in corresponding time wheel play sequence etc.
In in the cell of its modulus result.
In some embodiments, reallocation module 606 is used to execute the step S60 of above-mentioned any embodiment.
Further, in a preferred embodiment, information of freight source more new system further include:
Transferring module 607 refers to the circulation that the rear class time takes turns when the cycle index for taking turns when the rear class time moves forward
The update event in cell that needle currently points to migrates in each unit lattice taken turns to the adjacent prime time, until migrating to unit
In each unit lattice of the smallest time wheel of time value.
In some embodiments, transferring module 607 is used to execute step S701~S703 of above-mentioned any embodiment.
Above-mentioned information of freight source more new system is in such a way that the multistage time takes turns compound storage, using a small amount of memory space
A large amount of update event can be stored, is taken up less resources;And the update event of rear class time wheel can be migrated to the prime time and be taken turns,
Allow update event of the system according to the rotational frequency of the cycle index of the smallest time wheel of unit time value to information of freight source
It is executed and is reallocated, only needed to handle current partial task every time, reduce calculation amount, promote treatment effeciency.
The embodiment of the present invention also provides a kind of information of freight source more new equipment (hereinafter referred electronic equipment) based on time wheel,
Including processor and memory, executable instruction is stored in memory, processor is configured as via execution executable instruction
Come the step of executing the information of freight source update method based on time wheel in above-described embodiment.
As described above, electronic equipment of the invention the multistage time take turns compound storage by way of, using a small amount of storage
Space can store a large amount of update event, take up less resources;And the update event of rear class time wheel is when can migrate to prime
Between take turns, allow update of the system according to the rotational frequency of the cycle index of unit time value the smallest time wheel to information of freight source
Event is executed and is reallocated, and is only needed to handle current partial task every time, is reduced calculation amount, promotes treatment effeciency.
Fig. 7 is the structural schematic diagram of electronic equipment in the embodiment of the present invention, it should be appreciated that Fig. 7 is only schematic
Ground shows modules, these modules can be virtual software module or actual hardware module, the merging of these modules,
Fractionation and its increase of complementary modul block are all within protection scope of the present invention.
Person of ordinary skill in the field it is understood that various aspects of the invention can be implemented as system, method or
Program product.Therefore, various aspects of the invention can be embodied in the following forms, it may be assumed that complete hardware embodiment, complete
The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.) or hardware and software, can unite here
Referred to as " circuit ", " module " or " platform ".
The electronic equipment 700 of this embodiment according to the present invention is described referring to Fig. 7.The electronics that Fig. 7 is shown
Equipment 700 is only an example, should not function to the embodiment of the present invention and use scope bring any restrictions.
As shown in fig. 7, electronic equipment 700 is showed in the form of universal computing device.The component of electronic equipment 700 can wrap
Include but be not limited to: at least one processing unit 710, at least one storage unit 720, connection different platform component (including storage
Unit 720 and processing unit 710) bus 730, display unit 740 etc..
Wherein, storage unit is stored with program code, and program code can be executed with unit 710 processed, so that processing is single
Member 710 executes the examples various according to the present invention of the above-mentioned information of freight source update method part description based on time wheel of this specification
The step of property embodiment.For example, processing unit 710 can execute step as shown in Figure 1 respectively.
Storage unit 720 may include the readable medium of volatile memory cell form, such as Random Access Storage Unit
(RAM) 7201 and/or cache memory unit 7202, it can further include read-only memory unit (ROM) 7203.
Storage unit 720 can also include program/utility with one group of (at least one) program module 7205
7204, such program module 7205 includes but is not limited to: operating system, one or more application program, other program moulds
It may include the realization of network environment in block and program data, each of these examples or certain combination.
Bus 730 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage
Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures
Local bus.
Electronic equipment 700 can also be with one or more external equipments 800 (such as keyboard, sensing equipment, bluetooth equipment
Deng) communication, can also be enabled a user to one or more equipment interact with the electronic equipment 700 communicate, and/or with make
Any equipment (such as the router, modulation /demodulation that the electronic equipment 700 can be communicated with one or more of the other calculating equipment
Device etc.) communication.This communication can be carried out by input/output (I/O) interface 750.Also, electronic equipment 700 can be with
By network adapter 760 and one or more network (such as local area network (LAN), wide area network (WAN) and/or public network,
Such as internet) communication.Network adapter 760 can be communicated by bus 730 with other modules of electronic equipment 700.It should
Understand, although not shown in the drawings, other hardware and/or software module can be used in conjunction with electronic equipment 700, including but unlimited
In: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and number
According to backup storage platform etc..
The embodiment of the present invention also provides a kind of computer readable storage medium, and for storing program, program is performed reality
The step of information of freight source update method based on time wheel of existing above-described embodiment.In some possible embodiments, this hair
Bright various aspects are also implemented as a kind of form of program product comprising program code, when program product is set in terminal
When standby upper operation, program code is used to that terminal device to be made to execute the above-mentioned information of freight source update method based on time wheel of this specification
The step of various illustrative embodiments according to the present invention of part description.
As described above, computer readable storage medium of the invention in such a way that the multistage time takes turns compound storage, uses
A small amount of memory space can store a large amount of update event, take up less resources;And the update event of rear class time wheel can move
Prime time wheel is moved to, allows system according to the rotational frequency of the cycle index of the smallest time wheel of unit time value to the source of goods
The update event of information is executed and is reallocated, and only needs to handle current partial task every time, reduces calculation amount, promotion processing
Efficiency.
Fig. 8 is the structural schematic diagram of computer readable storage medium of the invention.Refering to what is shown in Fig. 8, describing according to this
The program product 900 for realizing the above method of the embodiment of invention can use the read-only storage of portable compact disc
Device (CD-ROM) and including program code, and can be run on terminal device, such as PC.However, journey of the invention
Sequence product is without being limited thereto, and in this document, readable storage medium storing program for executing can be any tangible medium for including or store program, the journey
Sequence can be commanded execution system, device or device use or in connection.
Program product can be using any combination of one or more readable mediums.Readable medium can be readable signal Jie
Matter or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can be but be not limited to electricity, magnetic, optical, electromagnetic, infrared ray or partly lead
System, device or the device of body, or any above combination.More specific example (the non exhaustive column of readable storage medium storing program for executing
Table) it include: the electrical connection with one or more conducting wires, portable disc, hard disk, random access memory (RAM), read-only storage
Device (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read only memory (CD-
ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
Computer readable storage medium may include in a base band or as carrier wave a part propagate data-signal,
In carry readable program code.The data-signal of this propagation can take various forms, including but not limited to electromagnetic signal,
Optical signal or above-mentioned any appropriate combination.Readable storage medium storing program for executing can also be any readable Jie other than readable storage medium storing program for executing
Matter, the readable medium can send, propagate or transmit for by instruction execution system, device or device use or and its
The program of combined use.The program code for including on readable storage medium storing program for executing can transmit with any suitable medium, including but not
It is limited to wireless, wired, optical cable, RF etc. or above-mentioned any appropriate combination.
The program for executing operation of the present invention can be write with any combination of one or more programming languages
Code, programming language include object oriented program language-Java, C++ etc., further include conventional process
Formula programming language-such as " C " language or similar programming language.Program code can be calculated fully in user
It executes in equipment, partly execute on a user device, executing, as an independent software package partially in user calculating equipment
Upper part executes on a remote computing or executes in remote computing device or server completely.It is being related to remotely counting
In the situation for calculating equipment, remote computing device can pass through the network of any kind, including local area network (LAN) or wide area network
(WAN) it is connected to user calculating equipment, or, it may be connected to external computing device (such as utilize ISP
To be connected by internet).
The above content is a further detailed description of the present invention in conjunction with specific preferred embodiments, and it cannot be said that
Specific implementation of the invention is only limited to these instructions.For those of ordinary skill in the art to which the present invention belongs, exist
Under the premise of not departing from present inventive concept, a number of simple deductions or replacements can also be made, all shall be regarded as belonging to of the invention
Protection scope.