CN107770258A - A kind of asynchronous call turns the implementation method of synchronization call - Google Patents

A kind of asynchronous call turns the implementation method of synchronization call Download PDF

Info

Publication number
CN107770258A
CN107770258A CN201710936510.3A CN201710936510A CN107770258A CN 107770258 A CN107770258 A CN 107770258A CN 201710936510 A CN201710936510 A CN 201710936510A CN 107770258 A CN107770258 A CN 107770258A
Authority
CN
China
Prior art keywords
call
proxy function
asynchronous
service end
synchronization
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
CN201710936510.3A
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.)
State Grid Corp of China SGCC
Xuji Group Co Ltd
XJ Electric Co Ltd
Original Assignee
State Grid Corp of China SGCC
Xuji Group Co Ltd
XJ Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Corp of China SGCC, Xuji Group Co Ltd, XJ Electric Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN201710936510.3A priority Critical patent/CN107770258A/en
Publication of CN107770258A publication Critical patent/CN107770258A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The present invention relates to the implementation method that a kind of asynchronous call turns synchronization call, this method can be by creating proxy function in client, need to be called mode change when, call request message is initiated from proxy function to service end, and lock proxy function, proxy function is set to enter wait state, when service end is called and returned, release proxy function locking, realize client and service end or other flows for needing to use asynchronous call mode to interact, it can be handled in the way of synchronization call, simplify the design of flow, introduce overtime design simultaneously, avoid process lock.

Description

A kind of asynchronous call turns the implementation method of synchronization call
Technical field
The invention belongs to the communication technical field in direct current transportation monitoring system, and in particular to a kind of asynchronous call turns synchronous The implementation method of calling.
Background technology
It is general to use the customer end/server mode based on network connection in the monitoring system of direct current transportation, and in visitor When family end needs to call the function of service end to perform some functions, generally there are two kinds of method of calling, asynchronous call or synchronization call.
So-called synchronization call, exactly when sending One function calling, before result is not obtained, the calling is not just returned Return.Fig. 1 is the schematic flow sheet for the synchronization call that a client obtains data from server end.In this synchronization call flow In, after client sends call request, the content of request performs in service end, and in this implementation procedure, client exists always Implementing result is waited, only after the request of service end terminates simultaneously returning result, client just continues downward execution.
Asynchronous concept and synchronization is relative.After an asynchronous procedure call is sent, result is not immediately available in caller. The part of this calling of actual treatment in the completed, caller is notified by state, notice and readjustment.Fig. 2 is a client Hold the schematic flow sheet for the asynchronous call that data are obtained from server end.In this asynchronous call flow, client sends tune After request, request content performs in service end, but client is not to wait for implementing result, and is to continue with performing downwards, services When the request of device performs end and returning result, client is continued executing with other processing function returning part.
The advantage of synchronization call is clear process, and logic is clear and definite, and asynchronous call is because can be in client and service end Perform simultaneously, therefore efficiency is higher.
In the monitoring system of direct current transportation, due to network call be in itself based on asynchronous system, therefore client and During server interaction, acquiescence is all asynchronous system.In most application scenarios, this mode be all it is proper, The acquisition and refreshing of such as data, asynchronous system execution efficiency is high, and does not wait mutually, and Consumer's Experience is good.But there are some should With scene, the execution such as ordered, because these application scenarios need to get implementing result at once, further according to implementing result not With the implementation procedure for judging next step, complex using flow during asynchronous call, Fig. 3 is an order in asynchronous mode Perform schematic flow sheet.It was found from from flow chart, in asynchronous mode, next step behaviour is just carried out after needing calling to be finished The step of making, be required for restarting a loop body, ceaselessly judge call execution state, cause in flow occur circulation and Branch, complex, if considering further that the failure possibility of each execution step, flow chart can be more complicated.Fig. 4 is synchronous mould Order under formula performs flow, from flow diagram, flow relative simplicity, and is all that order performs, and does not circulate and branch.
Therefore, how synchronization call is realized in asynchronous network, is worth discussion.
The content of the invention
The technical problems to be solved by the invention be just carried out after some application scenarios need calling to be finished it is next It is complex using flow during asynchronous call during step operation, it is then desired to obtain realizing synchronization in a kind of asynchronous call network Method.
In order to solve the above technical problems, the invention provides the implementation method that a kind of asynchronous call turns synchronization call, including Step:
1) a proxy function is created in client;
2) need to be called mode change when, asynchronous function call proxy function, sent out from proxy function to service end Call request message is played, proxy function is locked, proxy function is entered wait state;
3) when client monitors to service end, which are called, to be returned, proxy function locking is released, and records service end return Implementing result.
In step 2), while proxy function is locked, start timing, timing time-out is returned without receiving service end calling Proxy function locking is directly released when returning, and returns to the return value of acquiescence.
When network error causes funcall to malfunction, release proxy function and lock and return to the return value of acquiescence.
The return value of the acquiescence malfunctions to call.
The present invention sets proxy function using in client, initiates call request by proxy function, and initiating request Proxy function is locked simultaneously, proxy function is entered wait state, until when the calling that client receives service end returns, Release proxy function locking, the calling under script asynchronous mode, switch to synchronization call so that client and service end or its He needs to use the flow that asynchronous call mode interacts, and can be designed in the way of synchronization call, so as to simple flow Implementation procedure, meanwhile, by time-out processing, avoid process lock.
Brief description of the drawings
Fig. 1 is synchronization call schematic flow sheet;
Fig. 2 is asynchronous call schematic flow sheet;
Fig. 3 is the order execution flow chart under asynchronous mode;
Fig. 4 is the order execution flow chart under synchronous mode;
Fig. 5 is transition diagram of the asynchronous call of the present invention to synchronization call.
Embodiment
Technical scheme is described further below in conjunction with the accompanying drawings:
Handed over as shown in figure 5, being used for client in direct current transportation monitoring system the invention provides one kind with service end Mutual asynchronous call turns the implementation method of synchronization call, and this method comprises the following steps:
Step 101:A proxy function is created in client (function call side), for all asynchronous function calls;
Step 102:When need to be called mode change when, by this proxy function complete call, this function is taking It is engaged in before the implementing result return at end, all without return, i.e., locks proxy function;
The function call of service end is carried out in proxy function, and after calling initiation to terminate, will according to corresponding mark Proxy function locks, for making proxy function enter wait state;
Step 103:When service end is called and returned, client is notified by state, notice and readjustment, now releases generation Function locking is managed, and returns to implementing result.
, can not in order to prevent client to be absorbed in endless loop because the real-time of network transmission is limited by communication condition The mandatory restarting of client caused by response system message, and possibility, also add while proxy function is locked Clocking capability, and control agent function is jumped out after timing time-out.
Thus as the further improvement to this programme, while proxy function locks, this calling timing is given, is being counted When at the end of, if do not receive still service end call return, directly release proxy function locking, and return call out It is wrong.When preventing funcall error (such as network error, service end do not return abnormal), function will not deadlock, it is unlimited etc. to cause Treat.
Asynchronous call turns synchronization call embodiment:
Assuming that there is the mode of an asynchronous transmission order, but this subcommand is needed to carry out next life after being finished Order, the proxy function for needing during execution to be created using client are sent instruction " sendcmd+ spaces+command number " and arrive service end, and Proxy function is locked while sending and instructing, is waited for proxy function, service end, which receives, orders and verify success After can return to " receivecmd+ spaces+command number+check results ", after client receives return command, release proxy function Locking, while record the implementing result of return.The command number for once needing to perform is 10001, then the realization side of proxy function Formula and the data step sent are:
1) instruction " sendcmd 10001 " is sent;
2) proxy function is locked, into wait state;
3) timing is started while step 2);
4) judge whether to return, return value is recorded if returning and releases proxy function locking;
5) judge whether time-out, proxy function locking is released if time-out, while return to calling error;
6) 4-5 is repeated;
7) returned after unlocking.
In above-mentioned flow, as server successfully returns, then proxy function locking is released when performing step 4, is remembered simultaneously The return value of service end is recorded, as server returns not successfully, then proxy function locking, function return are released when performing step 5 The return value (be traditionally arranged to be time-out error or call error) of acquiescence.
The implementation method for turning synchronization call to a kind of asynchronous call of the present invention above is described in detail, and A specific embodiment is applied to be illustrated the principle and embodiment of the present invention, but the present invention be not limited to it is described Embodiment.The basic ideas of the present invention are above-mentioned basic scheme, for those of ordinary skill in the art, according to the present invention Teaching, design the models of various modifications, flow, method etc. and creative work need not be spent.The present invention is not being departed from Principle and spirit in the case of to embodiment carry out change, modification, replacement and modification still fall within the present invention protection model In enclosing.

Claims (4)

1. a kind of asynchronous call turns the implementation method of synchronization call, it is characterised in that including step:
1) a proxy function is created in client;
2) need to be called mode change when, asynchronous function call proxy function, initiate to adjust from proxy function to service end With request message, proxy function is locked, proxy function is entered wait state;
3) when client monitors to service end, which are called, to be returned, proxy function locking is released, and record the execution of service end return As a result.
2. asynchronous call according to claim 1 turns the implementation method of synchronization call, it is characterised in that in step 2), While locking proxy function, start timing, timing time-out acts on behalf of letter without receiving directly to release when service end is called and returned Number locking, and return to the return value of acquiescence.
3. asynchronous call according to claim 2 turns the implementation method of synchronization call, it is characterised in that when network error is made Call out and stagger the time into function, release proxy function and lock and return to the return value of acquiescence.
4. the asynchronous call according to Claims 2 or 3 turns the implementation method of synchronization call, it is characterised in that the acquiescence Return value for call malfunction.
CN201710936510.3A 2017-10-10 2017-10-10 A kind of asynchronous call turns the implementation method of synchronization call Pending CN107770258A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710936510.3A CN107770258A (en) 2017-10-10 2017-10-10 A kind of asynchronous call turns the implementation method of synchronization call

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710936510.3A CN107770258A (en) 2017-10-10 2017-10-10 A kind of asynchronous call turns the implementation method of synchronization call

Publications (1)

Publication Number Publication Date
CN107770258A true CN107770258A (en) 2018-03-06

Family

ID=61267096

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710936510.3A Pending CN107770258A (en) 2017-10-10 2017-10-10 A kind of asynchronous call turns the implementation method of synchronization call

Country Status (1)

Country Link
CN (1) CN107770258A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109067669A (en) * 2018-09-06 2018-12-21 华泰证券股份有限公司 Synchronization call method and application based on asynchronous interface
CN111435314A (en) * 2019-01-11 2020-07-21 武汉瓯越网视有限公司 Method, system, server and storage medium for waiting asynchronous message without blocking thread
CN113347151A (en) * 2021-04-28 2021-09-03 厦门海迈科技股份有限公司 Data interaction method based on socket shared memory

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060126657A1 (en) * 2004-12-15 2006-06-15 Michael Beisiegel Generating asynchronous interfaces and methods from synchronous interfaces and methods
CN101674326A (en) * 2009-09-21 2010-03-17 中兴通讯股份有限公司 Method for realizing interprocess synchronization communication and agent unit
CN102279774A (en) * 2011-08-22 2011-12-14 中兴通讯股份有限公司 Method and device for realizing multi-thread message interaction by using synchronous function calling mechanism

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060126657A1 (en) * 2004-12-15 2006-06-15 Michael Beisiegel Generating asynchronous interfaces and methods from synchronous interfaces and methods
CN101674326A (en) * 2009-09-21 2010-03-17 中兴通讯股份有限公司 Method for realizing interprocess synchronization communication and agent unit
CN102279774A (en) * 2011-08-22 2011-12-14 中兴通讯股份有限公司 Method and device for realizing multi-thread message interaction by using synchronous function calling mechanism

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李梅: "浅谈Node.js 异步编程中回调和异步调用的区别", 《通讯世界》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109067669A (en) * 2018-09-06 2018-12-21 华泰证券股份有限公司 Synchronization call method and application based on asynchronous interface
CN111435314A (en) * 2019-01-11 2020-07-21 武汉瓯越网视有限公司 Method, system, server and storage medium for waiting asynchronous message without blocking thread
CN113347151A (en) * 2021-04-28 2021-09-03 厦门海迈科技股份有限公司 Data interaction method based on socket shared memory

Similar Documents

Publication Publication Date Title
CN107770258A (en) A kind of asynchronous call turns the implementation method of synchronization call
EP1977554B1 (en) Ims budget control for a media change during an ims session
CN1964266B (en) IP multimedia subsystem gateway system and method able to check conversation status
CN104144186B (en) Data uploading method and system based on Web browser in cloud computing environment
CN102916825A (en) Management equipment of dual-computer hot standby system, management method and dual-computer hot standby system
CN101883355B (en) Collocation method and system of terminal parameter and terminal management device
CN105339892A (en) Local network and method of updating a device in a local network
CN113543281B (en) Voice communication method and voice communication device
US20150293759A1 (en) Method and System for Upgrading Patching Software
CN108279597A (en) A kind of computer interlocking platform courses method based on finite state machine
CN101252547B (en) Middleware system for realizing interactive increase value traffic based on IP set top box and method thereof
CN106878060A (en) The active and standby synchronization system and method for a kind of multi-service integrated access device
CN101635722B (en) TR-069 savepoints
CN102025728A (en) Scheduling method under client-side/server-side architecture and server
CN111200524B (en) Switch configuration method and server
CN110097330A (en) A kind of service request processing method, device and computer readable storage medium
CN110768816B (en) Multimedia service exception protection method and device
CN112948098B (en) Service unit offline method based on micro-service unit architecture and related device
CN114244678B (en) Multi-protocol alarm equipment access method and system
CN100488129C (en) Method for processing the batch configuration and network management device and network system
CN106357646B (en) Agent control system for storage management software
CN115348305A (en) Connection management method, system, computer device and storage medium
CN115640096A (en) Application management method and device based on kubernets and storage medium
CN101699884A (en) Method and system for realizing order relationship consistency between multiservice systems
CN104202548A (en) Network video recorder (NVR) multithreading management method and device

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: 20180306