CN109189595A - Event-handling method, device, equipment and medium based on server - Google Patents

Event-handling method, device, equipment and medium based on server Download PDF

Info

Publication number
CN109189595A
CN109189595A CN201811080179.0A CN201811080179A CN109189595A CN 109189595 A CN109189595 A CN 109189595A CN 201811080179 A CN201811080179 A CN 201811080179A CN 109189595 A CN109189595 A CN 109189595A
Authority
CN
China
Prior art keywords
event
thread
client
event data
server
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.)
Pending
Application number
CN201811080179.0A
Other languages
Chinese (zh)
Inventor
肖艳华
何华强
李进南
刘志宏
朱勇军
邓兵龙
吴韦盛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Yihua Computer Co Ltd
Shenzhen Yihua Time Technology Co Ltd
Shenzhen Yihua Financial Intelligent Research Institute
Original Assignee
Shenzhen Yihua Computer Co Ltd
Shenzhen Yihua Time Technology Co Ltd
Shenzhen Yihua Financial Intelligent Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Yihua Computer Co Ltd, Shenzhen Yihua Time Technology Co Ltd, Shenzhen Yihua Financial Intelligent Research Institute filed Critical Shenzhen Yihua Computer Co Ltd
Priority to CN201811080179.0A priority Critical patent/CN109189595A/en
Publication of CN109189595A publication Critical patent/CN109189595A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/508Monitor

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a kind of event-handling method based on server, device, equipment and storage mediums.The described method includes: the event handling request of at least one client transmission is monitored and received by main thread, sends and agree to response message to corresponding client;The client is added to buffering queue according to the event data that the agreement response message returns;Event data in the buffering queue is distributed to idle worker thread;The event data is handled by the worker thread;Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.According to the technical solution of the present invention, development difficulty can be effectively reduced while guaranteeing server application scalability, reduces maintenance cost, and improve the compatibility of server.

Description

Event-handling method, device, equipment and medium based on server
Technical field
The present embodiments relate to computer technology more particularly to a kind of event-handling method based on server, device, Equipment and medium.
Background technique
With the continuous development of financial industry, to the service ability of industry, more stringent requirements are proposed.Bank is in order to extend The scope of business of oneself has carried out effective trial in a variety of ranges.Consider from security and various aspects, the current data of bank The most still mode based on centralized data service of service, meets the place of a large number of services by laying a variety of server applications Reason demand.To meet such demand, server event processing routine with high performance is with regard to essential.It can locate for these The server event processing routine of a large number of services request is managed, in conjunction with the case where disparity items, each manufacturer can all be carried out pointedly Exploitation.
Currently, be directed to server program exploitation, common are two ways, one is using open source shell frame products, One is develop certainly.
The shell frame products of open source, such as ACE (ADAPTIVE Communication Environment, from adaptation communication Environment) etc., size of code is big, complex interfaces, and the iteration of version is uncontrolled, to application development company for, be easy by Various elbows processed.Moreover, these frame applications, are the needs to meet general signal procedure, and for specific manufacturer, Ke Neng great Most interfaces, code belong to redundancy, but such release maintenance, but partially cannot reduce related work less because of using Make.
Self-developed server program, for many amateur manufacturers, from the angle of development efficiency, Duo Shuohui Fairly simple development mode is selected, to meet the needs of project development.In the application program side for realizing concurrent processing multiple affair Face, have the programming model that the following two kinds is common: the pond of multi-process or multithreading handles model and event driven single-threaded model.
In the pond of multi-process or multithreading processing model, when in use due to the object inside pond, new request will not It can be accepted.So the application scalability of this model is poor, if application program need to only handle a small amount of concurrent request, system is also It can operate normally;But if application program needs to handle a large amount of request, a treatment progress or thread are distributed for each connection Mode be unpractical.
In event driven single-threaded model, due to the model can cause obstruction operation be converted into an asynchronous behaviour Make, therefore for handling model compared to the pond of multi-process or multithreading, scalability is high, and performance is also relatively good, but this mould All operations that will lead to obstruction are converted into asynchronous operation by type, and asynchronous operation needs are write and managed by developer, Development difficulty can be improved, maintenance cost is improved;On the other hand, many widely used function libraries are all difficult to switch to asynchronous at present Operation causes compatibility poor to realize.
Summary of the invention
The present invention provides a kind of event-handling method based on server, device, equipment and medium, is guaranteeing to take to realize While device application scalability of being engaged in, development difficulty is effectively reduced, reduces maintenance cost, and improve the compatibility of server.
In a first aspect, the present invention provides a kind of event-handling methods based on server, comprising:
The event handling request of at least one client transmission is monitored and received by main thread, is sent and is agreed to response message To corresponding client;
The client is added to buffering queue according to the event data that the agreement response message returns;
Event data in the buffering queue is distributed to idle worker thread;
The event data is handled by the worker thread;
Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.
Second aspect, the present invention also provides a kind of event processing apparatus based on server, which includes:
Event monitoring module, the event handling for the transmission of at least one client to be monitored and received by main thread are asked It asks, sends and agree to response message to corresponding client;
Queue adding module, for the client to be added to according to the event data that the agreement response message returns Buffering queue;
Data distribution module, for the event data in the buffering queue to be distributed to idle worker thread;
Data processing module, for being handled by the worker thread the event data;
Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.
The third aspect, the present invention also provides a kind of computer equipment, which includes:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the event-handling method based on server as described in any in the embodiment of the present invention.
Fourth aspect, the present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, should The event-handling method based on server as described in any in the embodiment of the present invention is realized when program is executed by processor.
The embodiment of the present invention is sent by the way that at least one client is monitored and received as the main thread of synchronization process thread Event handling request, and send agree to response message to corresponding client after, by client return event data add To buffering queue, and then the event data in the buffering queue is distributed to idle worker thread, is pressed by the worker thread Event data is handled according to asynchronous system, half synchronous half asynchronous advantage is utilized, and coordinate together using buffering queue Step and it is asynchronous between communication, solve in the prior art server application scalability is poor, development difficulty height, maintenance cost it is high Problem realizes while guaranteeing server application scalability, and development difficulty is effectively reduced, and reduces maintenance cost, and improve The effect of the compatibility of server.
Detailed description of the invention
Fig. 1 is a kind of flow diagram for event-handling method based on server that the embodiment of the present invention one provides;
Fig. 2 is a kind of structural schematic diagram of event processing apparatus based on server provided by Embodiment 2 of the present invention;
Fig. 3 is a kind of structural schematic diagram for computer equipment that the embodiment of the present invention three provides.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
Fig. 1 is a kind of flow diagram for event-handling method based on server that the embodiment of the present invention one provides.It should Method is applicable to the case where event that server sends client is handled, and this method can be by the thing based on server Part processing unit executes, which can be made of hardware and/or software, and can generally be integrated in server and all include In the computer equipment of Event handling.It specifically includes as follows:
S110, the event handling request monitored by main thread and receive the transmission of at least one client, send and agree to answer Information is answered to corresponding client.
In the present embodiment, main thread can be synchronization process thread.Illustratively, a main line can be used in the server Journey, according to synchronous mode monitor client transmission event handling request, and event handling request be verified be followed by by The request sends and agrees to response message to the client for sending the event handling request.It is described from kernel level, event handling Request can be socket request, namely when main thread listens to socket request, agree to the request, and notify phase The processing result for the client request answered, so that client continues to send connection socket to server.
In compared to the prior art in such a way that multithreading monitors request and handles event, the present embodiment passes through a master Thread is advantageous in that dedicated for monitoring event handling request, can save memory source.
Optionally, the event handling request of at least one client transmission is monitored and received by main thread, is sent and is agreed to Response message gives corresponding client, comprising: the shape for the file describing word bound in event notification interface is monitored by main thread State;If the state of file describing word becomes dbjective state, read from the corresponding read-write object of file describing word by main thread The event handling request for taking at least one client to send;Receive event handling request and send to agree to response message to corresponding Client.
Wherein, file describing word is a virtual sign, corresponds to a read-write object, the read-write object is for receiving visitor The event handling request that family end is sent.Illustratively, file describing word can be bundled in a specific event notification interface, The state that the file describing word bound in the event notification interface is monitored by main thread can be realized to the corresponding thing of the event The monitoring of part processing request.When the state of file describing word changes, it can notify that main thread is corresponding from file describing word The event handling request data that one or more clients are sent are read in read-write object.The thing that main thread reads each Part processing request carries out legitimate verification, receives the event handling request when being verified and sends corresponding feedback information to hair The client of the event handling request is given, to notify the client to carry out the transmission of next step event data.
Optionally, event notification interface is provided by event notification interface library libevent.
Since in the desktop of Linux and Windows these two types mainstream or server operating system, high performance event is logical Know that interface library libevent has been used as standard kernel interface or expanding library to be provided.It is driven as cross-platform based on event Dynamic interface library, libevent encapsulate the I/O multiplexing technology of multiple operating systems, and application developer does not have to be concerned about it The event interface exploitation under different platform can be completed using the unified interface of libevent in the specific implementation of bottom, so that While realizing high-performance concurrent server program, meet the cross-platform use needs of server program.In addition, in the portion of project Belong to aspect, event notification interface library libevent does not have to complicated configuration as other framework server programs, related dependant Library is fairly simple.For example, under linux, the library libevent has been standard interface library, direct use;In Windows Under, it is only necessary to a subsidiary upper libevent.dll dynamic base avoids similar ACE running environment too fat to move like that.
S120, client is added to buffering queue according to the event data for agreeing to that response message returns.
The present embodiment coordinates the communication between asynchronous and synchronous in such a way that event data is added to buffering queue, So that the event data that client returns can be distributed to each worker thread after main thread listens to request according to the method for synchronization, So that each worker thread is handled according to asynchronous system.
Illustratively, the event data being added can be carried out according to the receiving time of each event data in buffering queue Arrangement, in order to be distributed processing according to putting in order to the event data in buffering queue in subsequent operation.Wherein, client End can be connection request, such as connection socket according to the event data for agreeing to response message return;It is also possible to connection to ask Summation business datum, for example, the business datum or server that send simultaneously with connection request establish connection according to connection request The business datum that client is sent later, is not limited thereto.
Since the size of buffering queue can be adjusted and extend according to actual needs, it enables the server to Multiple concurrent event requests being handled, without will cause data jamming, to improve the application scalability of server, and being located It can guarantee that the process performance of server is unaffected when managing high concurrent event.
S130, the event data in buffering queue is distributed to idle worker thread.
Illustratively, it may include multiple worker threads in server, will be buffered by the case distribution module in server Each event data in queue is distributed to the worker thread of current idle.Wherein, idle worker thread includes but is not limited to The processed worker thread finished of an a upper event data and/or upper event data is also untreated finishes, but the work of current idle Make thread, such as is currently at the worker thread for waiting client end response.
A concrete instance is lifted, when there is new event handling request to reach, main thread receives the request, and will newly return Connection socket be put into buffering queue, while by the read-write event registration on the socket into kernel events table, with touching The case distribution module in server is sent out according to the read-write event registered on kernel events table, by the connection in buffering queue Socket is distributed to idle worker thread.
S140, event data is handled by worker thread.
Wherein, worker thread is asynchronous process thread, can handle each event data according to asynchronous system.To event data Carrying out asynchronous process is advantageous in that, can promote the treatment effeciency to event data, improves server performance, simultaneously as Carry out the event data of stalled store using buffering queue, therefore, is converted into asynchronous operation in the operation that not will lead to obstruction In the case of, the data jamming problem in asynchronous process also can be effectively avoided, thus not only ensure that the performance of server, but also Development difficulty is effectively reduced, reduces maintenance cost, and improve the compatibility of server.
Optionally, when event data is connection request, correspondingly, event data is handled by worker thread, It include: the interface channel established according to connection request between worker thread and client;By worker thread to logical based on connection The received business datum in road is handled.
A concrete instance is lifted, when worker thread is assigned to connection socket, the work can be established according to the socket Make the interface channel between thread and client, and carries out the communication of business datum based on the interface channel, namely next should Any I/O operation on socket is all handled by the worker thread, and the interface channel, Huo Zheke are closed after the completion of processing Family end has actively closed the interface channel because of other reasons.Description is exactly that main thread is only responsible for monitoring from kernel level Socket request, the specific processing for connecting socket are responsible for by worker thread.
The technical solution of the present embodiment, by being monitored as the main thread of synchronization process thread and receiving at least one client Hold send event handling request, and send agree to response message to corresponding client after, by client return event number According to being added to buffering queue, and then the event data in the buffering queue is distributed to idle worker thread, passes through the work Thread is handled event data according to asynchronous system, half synchronous half asynchronous advantage is utilized, and use buffering queue Coordinate synchronization and it is asynchronous between communication, solve in the prior art server application scalability is poor, development difficulty is high, maintenance at This high problem realizes while guaranteeing server application scalability, and development difficulty is effectively reduced, and reduces maintenance cost, And improve the effect of the compatibility of server.
On the basis of the above embodiments, optionally, if event data includes connection request and business datum, accordingly , the event data in buffering queue is distributed to idle worker thread, comprising: if it is determined that event data is connection request, Then connection request is registered in internal event table, and the connection request of registration is successively distributed to by the free time according to internal event table Worker thread;If it is determined that event data is business datum, and target operation thread corresponding with business datum is idle state, Business datum is then distributed into target operation thread.
In practical applications, since data transmission is easy to be influenced by network fluctuation, it is likely to result in client simultaneously The connection request of transmission and corresponding business datum, when being finally transferred to server, server receives only connection request, and It is just received after corresponding business datum delay a period of time.In order to solve to cause because of network fluctuation to repeat to divide to same event The problem of with worker thread, can first detect whether the event data is connection request when carrying out event data distribution, if so, Then by the way that the connection request is registered to internal event table, to distribute them to new idle worker thread;If detecting this Event data is business datum, then assigns them to corresponding target operation thread, wherein target operation thread is to handle the industry The worker thread of the corresponding connection request of data of being engaged in.Specifically, by business datum distribute to corresponding target operation thread it Before, can first determine whether the target operation thread is idle state, if so, being distributed directly to the target operation thread;If it is not, It reallocates when then waiting the target operation thread free time and gives the target operation thread.
Embodiment two
Fig. 2 is a kind of structural schematic diagram of the event processing apparatus based on server provided by Embodiment 2 of the present invention.Ginseng Fig. 2 is examined, the event processing apparatus based on server includes: event monitoring module 210, queue adding module 220, data distribution mould Block 230 and data processing module 240, are below specifically described each module.
Event monitoring module 210, for the event handling of at least one client transmission to be monitored and received by main thread Request sends and agrees to response message to corresponding client;
Queue adding module 220, for adding the client according to the event data that the agreement response message returns Add to buffering queue;
Data distribution module 230, for the event data in the buffering queue to be distributed to idle worker thread;
Data processing module 240, for being handled by the worker thread the event data;
Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.
Event processing apparatus provided in this embodiment based on server passes through the main thread prison as synchronization process thread Listen and receive at least one client transmission event handling request, and send agree to response message to corresponding client after, The event data that client returns is added to buffering queue, and then the event data in the buffering queue is distributed to the free time Worker thread is handled event data according to asynchronous system by the worker thread, and it is asynchronous excellent to be utilized half synchronous half Point, and using buffering queue come coordinate synchronization and it is asynchronous between communication, solve server application scalability in the prior art The problem that difference, development difficulty are high, maintenance cost is high, realizes while guaranteeing server application scalability, is effectively reduced out Degree of raising difficult questions reduces maintenance cost, and improves the effect of the compatibility of server.
Optionally, the event data includes connection request;
Data processing module 240 specifically can be used for:
The interface channel between the worker thread and the client is established according to the connection request;
It is handled by the worker thread based on the received business datum of the interface channel.
Optionally, the event data includes connection request and business datum;
Data distribution module 230 specifically can be used for:
If it is determined that the event data is connection request, then the connection request is registered in internal event table, and root The connection request of registration is successively distributed to idle worker thread according to the internal event table;
If it is determined that the event data is business datum, and target operation thread corresponding with the business datum is the free time The business datum is then distributed to the target operation thread by state.
Optionally, event monitoring module 210 specifically can be used for:
The state for the file describing word bound in event notification interface is monitored by main thread;
If the state of the file describing word becomes dbjective state, by the main thread from the file describing word pair The event handling request of at least one client transmission is read in the read-write object answered;
Receive the event handling request and send to agree to response message to corresponding client.
Optionally, the event notification interface is provided by event notification interface library libevent.
Method provided by any embodiment of the invention can be performed in the said goods, has the corresponding functional module of execution method And beneficial effect.
Embodiment three
Fig. 3 is a kind of structural schematic diagram for computer equipment that the embodiment of the present invention four provides, as shown in figure 3, this implementation A kind of computer equipment that example provides, comprising: processor 31 and memory 32.Processor in the computer equipment can be one A or multiple, in Fig. 3 by taking a processor 31 as an example, processor 31 and memory 32 in the computer equipment can pass through Bus or other modes connect, in Fig. 3 for being connected by bus.
The thing provided by the above embodiment based on server is integrated in the present embodiment in the processor 31 of computer equipment Part processing unit.In addition, the memory 32 in the computer equipment is used as a kind of computer readable storage medium, can be used for storing One or more programs, described program can be software program, computer executable program and module, such as embodiment of the present invention In the corresponding program instruction/module of the event-handling method based on server (for example, the attached thing shown in Fig. 2 based on server Module in part processing unit, comprising: event monitoring module 210, queue adding module 220, data distribution module 230 and number According to processing module 240).Software program, instruction and module of the processor 31 by operation storage in memory 32, to hold The various function application and data processing of row equipment, i.e. the event handling side based on server in realization above method embodiment Method.
Memory 32 may include storing program area and storage data area, wherein storing program area can storage program area, extremely Application program needed for a few function;Storage data area, which can be stored, uses created data etc. according to equipment.In addition, depositing Reservoir 32 may include high-speed random access memory, can also include nonvolatile memory, and a for example, at least disk is deposited Memory device, flush memory device or other non-volatile solid state memory parts.In some instances, memory 32 can further comprise The memory remotely located relative to processor 31, these remote memories can pass through network connection to equipment.Above-mentioned network Example include but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Also, when one or more included program of above-mentioned computer equipment is by one or more of processors 31 When execution, program is proceeded as follows:
The event handling request of at least one client transmission is monitored and received by main thread, is sent and is agreed to response message To corresponding client;Client is added to buffering queue according to the event data for agreeing to that response message returns;Team will be buffered Event data in column is distributed to idle worker thread;Event data is handled by worker thread;Wherein, main thread For synchronization process thread, worker thread is asynchronous process thread.
Example IV
The embodiment of the present invention four additionally provides a kind of computer readable storage medium, is stored thereon with computer program, should The thing based on server provided such as the embodiment of the present invention one is provided when program is executed by the event processing apparatus based on server Part processing method, this method comprises: the event handling request of at least one client transmission is monitored and received by main thread, hair It send and agrees to response message to corresponding client;Client is added to buffering according to the event data for agreeing to that response message returns Queue;Event data in buffering queue is distributed to idle worker thread;By worker thread to event data at Reason;Wherein, main thread is synchronization process thread, and worker thread is asynchronous process thread.
Certainly, a kind of computer readable storage medium provided by the embodiment of the present invention, the computer program stored thereon It is performed and is not limited to realize method operation as described above, can also realize provided by any embodiment of the invention based on clothes The relevant operation being engaged in the event-handling method of device.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art Part can be embodied in the form of software products, which can store in computer readable storage medium In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set Standby (can be personal computer, server or the network equipment etc.) executes method described in each embodiment of the present invention.
It is worth noting that, in the embodiment of the above-mentioned event processing apparatus based on server, included each unit It is only divided according to the functional logic, but is not limited to the above division with module, as long as can be realized corresponding function Energy;In addition, the specific name of each functional unit is also only for convenience of distinguishing each other, the guarantor being not intended to restrict the invention Protect range.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.

Claims (10)

1. a kind of event-handling method based on server characterized by comprising
The event handling request of at least one client transmission is monitored and received by main thread, is sent and is agreed to response message to right The client answered;
The client is added to buffering queue according to the event data that the agreement response message returns;
Event data in the buffering queue is distributed to idle worker thread;
The event data is handled by the worker thread;
Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.
2. the method according to claim 1, wherein the event data includes connection request;
The event data is handled by the worker thread, comprising:
The interface channel between the worker thread and the client is established according to the connection request;
It is handled by the worker thread based on the received business datum of the interface channel.
3. the method according to claim 1, wherein the event data includes connection request and business number According to;
Event data in the buffering queue is distributed to idle worker thread, comprising:
If it is determined that the event data is connection request, then the connection request is registered in internal event table, and according to institute It states internal event table and the connection request of registration is successively distributed to idle worker thread;
If it is determined that the event data is business datum, and target operation thread corresponding with the business datum is idle shape The business datum is then distributed to the target operation thread by state.
4. the method according to claim 1, wherein described monitored by main thread and receive at least one client The event handling request sent is held, sends and agrees to response message to corresponding client, comprising:
The state for the file describing word bound in event notification interface is monitored by main thread;
It is corresponding from the file describing word by the main thread if the state of the file describing word becomes dbjective state The event handling request of at least one client transmission is read in read-write object;
Receive the event handling request and send to agree to response message to corresponding client.
5. according to the method described in claim 4, it is characterized in that, the event notification interface is by event notification interface library Libevent is provided.
6. a kind of event processing apparatus based on server characterized by comprising
Event monitoring module, for the event handling request of at least one client transmission, hair to be monitored and received by main thread It send and agrees to response message to corresponding client;
Queue adding module, for the client to be added to buffering according to the event data that the agreement response message returns Queue;
Data distribution module, for the event data in the buffering queue to be distributed to idle worker thread;
Data processing module, for being handled by the worker thread the event data;
Wherein, the main thread is synchronization process thread, and the worker thread is asynchronous process thread.
7. device according to claim 6, which is characterized in that the event data includes connection request;
The data processing module is specifically used for:
The interface channel between the worker thread and the client is established according to the connection request;
It is handled by the worker thread based on the received business datum of the interface channel.
8. device according to claim 6, which is characterized in that the event data includes connection request and business number According to;
The data distribution module is specifically used for:
If it is determined that the event data is connection request, then the connection request is registered in internal event table, and according to institute It states internal event table and the connection request of registration is successively distributed to idle worker thread;
If it is determined that the event data is business datum, and target operation thread corresponding with the business datum is idle shape The business datum is then distributed to the target operation thread by state.
9. a kind of computer equipment, which is characterized in that the equipment includes:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as the event-handling method as claimed in any one of claims 1 to 5 based on server.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor Such as the event-handling method as claimed in any one of claims 1 to 5 based on server is realized when execution.
CN201811080179.0A 2018-09-17 2018-09-17 Event-handling method, device, equipment and medium based on server Pending CN109189595A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811080179.0A CN109189595A (en) 2018-09-17 2018-09-17 Event-handling method, device, equipment and medium based on server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811080179.0A CN109189595A (en) 2018-09-17 2018-09-17 Event-handling method, device, equipment and medium based on server

Publications (1)

Publication Number Publication Date
CN109189595A true CN109189595A (en) 2019-01-11

Family

ID=64911297

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811080179.0A Pending CN109189595A (en) 2018-09-17 2018-09-17 Event-handling method, device, equipment and medium based on server

Country Status (1)

Country Link
CN (1) CN109189595A (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147269A (en) * 2019-05-09 2019-08-20 腾讯科技(上海)有限公司 A kind of event-handling method, device, equipment and storage medium
CN111258779A (en) * 2020-01-13 2020-06-09 中孚安全技术有限公司 C + + 11-based network communication method and system
CN111447263A (en) * 2020-03-24 2020-07-24 中国建设银行股份有限公司 Message communication system
CN112631788A (en) * 2021-01-06 2021-04-09 上海哔哩哔哩科技有限公司 Data transmission method and data transmission server
CN112995198A (en) * 2021-03-29 2021-06-18 中信银行股份有限公司 Short-connection communication method and device based on socket
CN113051243A (en) * 2021-03-31 2021-06-29 上海阵量智能科技有限公司 Log processing method, device, system, chip, equipment and storage medium
CN113127204A (en) * 2021-04-29 2021-07-16 四川虹美智能科技有限公司 Method and server for processing concurrent services based on reactor network model
CN113256877A (en) * 2020-12-31 2021-08-13 深圳怡化电脑股份有限公司 Paper money information management method, device, storage medium and computer equipment
CN113409109A (en) * 2021-06-11 2021-09-17 北京达佳互联信息技术有限公司 Order creation method, device, server and storage medium
CN113515320A (en) * 2021-05-26 2021-10-19 新华三信息技术有限公司 Hardware acceleration processing method and device and server
CN114168626A (en) * 2021-12-13 2022-03-11 中国建设银行股份有限公司 Database operation processing method, device, equipment and medium
CN115033399A (en) * 2022-06-09 2022-09-09 上海介方信息技术有限公司 Lightweight event service method and system based on CORBA middleware
CN116841772A (en) * 2023-08-30 2023-10-03 成都中科合迅科技有限公司 Cross-thread signal processing method and system based on event queue
CN117082307A (en) * 2023-10-13 2023-11-17 天津幻彩科技有限公司 Three-dimensional scene stream data play control method and device based on fluency improvement

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276983A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Automatic return to synchronization context for asynchronous computations
CN102546808A (en) * 2012-01-17 2012-07-04 深圳天源迪科信息技术股份有限公司 Interactive processing method based on TCP (Transmission Control Protocol) of server
CN102780837A (en) * 2012-07-13 2012-11-14 成都东方盛行电子有限责任公司 Method for intelligently synchronizing generic edition platform cloud disc file and media resource system
CN103795569A (en) * 2014-01-22 2014-05-14 亿赞普(北京)科技有限公司 Server connection method and device based on connection pool
CN104184635A (en) * 2014-08-19 2014-12-03 烽火通信科技股份有限公司 Method and device of home gateway for achieving one-to-many data communication based on Android RIL
CN107634984A (en) * 2017-08-07 2018-01-26 国网河南省电力公司 A kind of file synchronisation method based on one-way transmission path

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110276983A1 (en) * 2010-05-05 2011-11-10 Microsoft Corporation Automatic return to synchronization context for asynchronous computations
CN102546808A (en) * 2012-01-17 2012-07-04 深圳天源迪科信息技术股份有限公司 Interactive processing method based on TCP (Transmission Control Protocol) of server
CN102780837A (en) * 2012-07-13 2012-11-14 成都东方盛行电子有限责任公司 Method for intelligently synchronizing generic edition platform cloud disc file and media resource system
CN103795569A (en) * 2014-01-22 2014-05-14 亿赞普(北京)科技有限公司 Server connection method and device based on connection pool
CN104184635A (en) * 2014-08-19 2014-12-03 烽火通信科技股份有限公司 Method and device of home gateway for achieving one-to-many data communication based on Android RIL
CN107634984A (en) * 2017-08-07 2018-01-26 国网河南省电力公司 A kind of file synchronisation method based on one-way transmission path

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
NEARMENG: "libevent和基于libevent的网络编程", 《HTTPS://WWW.CNBLOGS.COM/NEARMENG/P/4043548.HTML》 *
刘燚: "半同步半异步线程池的设计与实现", 《计算机与现代化》 *
贺大卫: "Libevent", 《HTTPS://WWW.CNBLOGS.COM/VIRUSOLF/P/5206360.HTML》 *

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147269A (en) * 2019-05-09 2019-08-20 腾讯科技(上海)有限公司 A kind of event-handling method, device, equipment and storage medium
CN111258779A (en) * 2020-01-13 2020-06-09 中孚安全技术有限公司 C + + 11-based network communication method and system
CN111447263A (en) * 2020-03-24 2020-07-24 中国建设银行股份有限公司 Message communication system
CN113256877A (en) * 2020-12-31 2021-08-13 深圳怡化电脑股份有限公司 Paper money information management method, device, storage medium and computer equipment
CN113256877B (en) * 2020-12-31 2024-02-02 深圳怡化电脑股份有限公司 Banknote information management method, banknote information management device, banknote information management storage medium, and computer device
CN112631788A (en) * 2021-01-06 2021-04-09 上海哔哩哔哩科技有限公司 Data transmission method and data transmission server
CN112631788B (en) * 2021-01-06 2023-11-28 上海哔哩哔哩科技有限公司 Data transmission method and data transmission server
WO2022148363A1 (en) * 2021-01-06 2022-07-14 上海哔哩哔哩科技有限公司 Data transmission method and data transmission server
CN112995198A (en) * 2021-03-29 2021-06-18 中信银行股份有限公司 Short-connection communication method and device based on socket
CN113051243A (en) * 2021-03-31 2021-06-29 上海阵量智能科技有限公司 Log processing method, device, system, chip, equipment and storage medium
CN113127204A (en) * 2021-04-29 2021-07-16 四川虹美智能科技有限公司 Method and server for processing concurrent services based on reactor network model
CN113515320A (en) * 2021-05-26 2021-10-19 新华三信息技术有限公司 Hardware acceleration processing method and device and server
CN113409109B (en) * 2021-06-11 2024-04-09 北京达佳互联信息技术有限公司 Order creation method, device, server and storage medium
CN113409109A (en) * 2021-06-11 2021-09-17 北京达佳互联信息技术有限公司 Order creation method, device, server and storage medium
CN114168626A (en) * 2021-12-13 2022-03-11 中国建设银行股份有限公司 Database operation processing method, device, equipment and medium
CN115033399B (en) * 2022-06-09 2023-03-17 上海介方信息技术有限公司 Lightweight event service method and system based on CORBA middleware
CN115033399A (en) * 2022-06-09 2022-09-09 上海介方信息技术有限公司 Lightweight event service method and system based on CORBA middleware
CN116841772B (en) * 2023-08-30 2023-11-07 成都中科合迅科技有限公司 Cross-thread signal processing method and system based on event queue
CN116841772A (en) * 2023-08-30 2023-10-03 成都中科合迅科技有限公司 Cross-thread signal processing method and system based on event queue
CN117082307A (en) * 2023-10-13 2023-11-17 天津幻彩科技有限公司 Three-dimensional scene stream data play control method and device based on fluency improvement
CN117082307B (en) * 2023-10-13 2023-12-29 天津幻彩科技有限公司 Three-dimensional scene stream data play control method and device based on fluency improvement

Similar Documents

Publication Publication Date Title
CN109189595A (en) Event-handling method, device, equipment and medium based on server
US9344494B2 (en) Failover data replication with colocation of session state data
US10133596B2 (en) System and method for supporting application interoperation in a transactional middleware environment
US8954786B2 (en) Failover data replication to a preferred list of instances
US8862933B2 (en) Apparatus, systems and methods for deployment and management of distributed computing systems and applications
US8381016B2 (en) Fault tolerance for map/reduce computing
CN107451147B (en) Method and device for dynamically switching kafka clusters
US20120215920A1 (en) Optimized resource management for map/reduce computing
US20140149590A1 (en) Scaling computing clusters in a distributed computing system
Essa et al. Mobile agent based new framework for improving big data analysis
US9654582B2 (en) Enhanced shared memory based communication driver for improved performance and scalability
US10691501B1 (en) Command invocations for target computing resources
CN109245962A (en) Server monitoring method, system, computer equipment and storage medium
Mohamed et al. MidCloud: an agent‐based middleware for effective utilization of replicated Cloud services
US20200310828A1 (en) Method, function manager and arrangement for handling function calls
US10313450B2 (en) Method for transparently connecting augmented network socket operations
CN105373563B (en) Database switching method and device
Fazio et al. Managing volunteer resources in the cloud
CN105262796A (en) Cloud platform storage resource management system and disposition framework thereof
CN102868594B (en) Method and device for message processing
CN109614242A (en) A kind of computing capability sharing method, device, equipment and medium
US20220179790A1 (en) Fault tolerant cluster data handling
US20200236146A1 (en) System and method for embedding external infrastructure services into management nodes
CN106844058B (en) Management method and device for virtualized resources
US20240118881A1 (en) Firmware updates in a data center

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190111