[go: up one dir, main page]

WO2019001073A1 - 一种远程过程调用的方法、装置及计算机设备 - Google Patents

一种远程过程调用的方法、装置及计算机设备 Download PDF

Info

Publication number
WO2019001073A1
WO2019001073A1 PCT/CN2018/082162 CN2018082162W WO2019001073A1 WO 2019001073 A1 WO2019001073 A1 WO 2019001073A1 CN 2018082162 W CN2018082162 W CN 2018082162W WO 2019001073 A1 WO2019001073 A1 WO 2019001073A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
processing function
synchronization processing
call request
global dictionary
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.)
Ceased
Application number
PCT/CN2018/082162
Other languages
English (en)
French (fr)
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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Publication of WO2019001073A1 publication Critical patent/WO2019001073A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]

Definitions

  • the invention belongs to the technical field of communications, and in particular relates to a method, a device and a computer device for remote procedure call.
  • a remote procedure call is a method provided by one process to call another process, suitable for communication between processes.
  • the present invention provides a method, apparatus and computer device for remote procedure call to solve the above problems in the prior art.
  • the present invention provides a method, a device, and a computer device for remote procedure call, which are used to solve the problem of constructing a remote procedure call model when performing remote procedure call in the prior art.
  • the present invention provides a method of remote procedure call, the method comprising:
  • the target synchronization processing function is executed in an asynchronous thread, and an execution result is acquired and transmitted.
  • the target synchronization processing function is executed in an asynchronous thread, including:
  • the target synchronization processing function is posted to the asynchronous thread based on the parameter information, and the target synchronization processing function is executed in the asynchronous thread.
  • the obtaining and sending the execution result includes:
  • the identifier and the execution result are serialized into a network message, and the network message is sent.
  • the name of the pre-agreed remote method and the corresponding synchronization processing function are registered in the global dictionary, including:
  • the RpcRegisterProcedure function is called to register the name of the pre-agreed remote method and the synchronization processing function corresponding to the remote method into the global dictionary.
  • the method further includes:
  • a result set is returned, the result set including an indication value indicating that there is no search result.
  • the synchronization processing function is specifically: IRpcArgumentArray*(*RpcProcedure)(void*caller, IRpcArgument**args, int numArgs); wherein the IRpcArgumentArray is a set of arrays, and is used to store the execution result;
  • the args is the parameter information in the target call request;
  • the numArgs is the number of the args parameters.
  • the present invention also provides an apparatus for remote procedure call, the apparatus comprising:
  • a registration unit configured to register the name of the pre-agreed remote method and the corresponding synchronization processing function into the global dictionary
  • a receiving unit configured to receive a target call request
  • a determining unit configured to determine, according to the target calling request, whether the target synchronization processing function corresponding to the target calling request is found in the global dictionary
  • an execution unit configured to: if the target synchronization processing function can be found in the global dictionary, execute the target synchronization processing function in an asynchronous thread to acquire and send an execution result.
  • the execution unit is specifically configured to:
  • the target synchronization processing function is posted to the asynchronous thread based on the parameter information, and the target synchronization processing function is executed in the asynchronous thread.
  • the present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the following steps:
  • the target synchronization processing function is executed in an asynchronous thread, and an execution result is acquired and transmitted.
  • the invention also provides a remote process call computer device, comprising:
  • At least one processor At least one processor
  • At least one memory communicatively coupled to the processor, wherein
  • the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of the above.
  • the present invention provides a remote procedure call method, apparatus and computer apparatus, the method comprising: registering a name of a pre-agreed remote method and a corresponding synchronization processing function into a global dictionary; receiving a target call request; Determining, by the target call request, whether the target synchronization processing function corresponding to the call request can be found in the global dictionary; if the target synchronization processing function can be found in the global dictionary, executing the target in the asynchronous thread
  • the synchronization processing function acquires and sends the execution result; thus, the called end can synchronously respond to the call request from the calling end, and only needs to register the synchronization processing function in the global dictionary before receiving the target calling request, and receive the target calling request. Then, according to the call request, a signal path of a remote procedure call can be quickly established, and then the synchronous processing function is executed, and the execution result is returned to the calling end, thereby improving work efficiency.
  • FIG. 1 is a schematic flowchart of a method for remote procedure call according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for remote procedure call according to Embodiment 2 of the present invention.
  • FIG. 3 is a schematic diagram of the overall structure of a computer device for remote procedure call according to Embodiment 3 of the present invention.
  • This embodiment provides a method for remote procedure call. As shown in FIG. 1, the method includes:
  • the RpcRegisterProcedure function needs to be called to register the name of the pre-agreed remote method and the synchronization processing function corresponding to the remote method to the global dictionary Dict, so that when the call request is received, the request can be directly Find the corresponding synchronization processing function in the global dictionary Dict, quickly build a remote procedure call model, and improve processing efficiency.
  • the pre-agreed remote method is pre-agreed by the calling end and the called end.
  • the model of the synchronization processing function is: IRpcArgumentArray*(*RpcProcedure)(void*caller, IRpcArgument**args, int numArgs); wherein the IRpcArgumentArray is an array collection of an IRpcArgument structure for storing the execution result
  • the caller, the IRpcArgument is an identification parameter; the args is parameter information in the target call request; the numArgs is the number of the args parameter.
  • S102 Receive a target call request, and determine, according to the target call request, whether a target synchronization processing function corresponding to the target call request can be found in the global dictionary.
  • the receiving call end calls the target call request sent by the RpcCallProcedure function, and judges in the global dictionary based on the target calling request. Whether the target synchronization processing function corresponding to the target call request can be found.
  • the target call request includes information such as a name of a pre-agreed remote method.
  • the target synchronization processing function corresponding to the call request can be found in the global dictionary.
  • the procedure field in the RpcMessage message represents the remote method name to be called, and the target synchronization processing function RpcProcedure is looked up in the global dictionary Dict according to the method name.
  • the target synchronization processing function can be found in the global dictionary, execute the target synchronization processing function in an asynchronous thread, and acquire and send an execution result.
  • the parameter information is obtained from the RpcMessage message; specifically, the IRpcArgument structure is obtained from the RpcMessage message by calling the GetRpcArgsFromMessage function, and then the IRpcArgument structure is called.
  • the parameter obtaining method i32Value acquires parameter information in the target calling request.
  • the identifier is a unique identifier of the target call request, and is used to distinguish from other call requests to avoid confusion; Yes, there is a unique identifier for each invocation request.
  • the calling end calls the RpcCallProcedure function to send a target call request to the called end
  • an identifier is generated, and the identifier is written into the gid field of the RpcMessage message, and when the called end receives the RpcMessage message,
  • the identifier in the target call request can be obtained from the gid field.
  • the target synchronization processing function After the identifier is obtained, all the parameter information is provided to the target synchronization processing function, specifically, the first identifier is assigned to the identification parameter caller of the target synchronization processing function, IRpcArgument, and the parameter information in the target call request is Assigning to args, assigning the number of parameter information to numArgs; in order to avoid blocking of the main thread and improving processing efficiency, the target synchronization processing function is delivered to the asynchronous thread, and the target synchronization processing function is executed in the asynchronous thread RpcProcedure, get the execution result.
  • the first value is ERROR_OK, which is used to inform the calling end that the remote call is successful; the first value is IRpcArgumentArray.
  • the BuildRpcMessageFrom method is called to serialize the result set of the execution result into a network message, and the gid field in the network message is set as an identifier, and the rpcType field in the network message is set to an RPC_MESSAGE_RESPONSE value, indicating that the network message is a Remote response message.
  • the method further includes: returning a result set, where the result set includes an indication value for indicating that there is no search result, and the content of the indication value is ERROR_RPC_NOT_FOUND, for Tell the caller that the called process does not have the remote procedure method.
  • the embodiment further provides a remote procedure call device.
  • the remote procedure call device includes: a registration unit 21, a receiving unit 22, a determining unit 23, and an executing unit 24; ,
  • the registration unit 21 Before receiving the call request, the registration unit 21 needs to call the RpcRegisterProcedure function to register the name of the pre-agreed remote method and the synchronization processing function corresponding to the remote method into the global dictionary Dict, so that when the call request is received, Find the corresponding synchronization processing function directly in the global dictionary Dict, quickly build a remote procedure call model, and improve processing efficiency.
  • the pre-agreed remote method is pre-agreed by the calling end and the called end.
  • the model of the synchronization processing function is: IRpcArgumentArray*(*RpcProcedure)(void*caller, IRpcArgument**args, int numArgs); wherein the IRpcArgumentArray is an array collection of an IRpcArgument structure for storing the execution result
  • the caller, the IRpcArgument is an identification parameter; the args is parameter information in the target call request; the numArgs is the number of the args parameter.
  • the receiving unit 22 is configured to receive a target calling request sent by the calling end to call the RpcCallProcedure function, based on the target calling request, Determining whether the target synchronization processing function corresponding to the call request can be found in the global dictionary.
  • the target call request includes information such as a name of a pre-agreed remote method.
  • the receiving unit 22 acquires the name of the remote method, and the determining unit 23 may determine, according to the name, whether the Call the target synchronization handler corresponding to the request.
  • the procedure field in the RpcMessage message represents the remote method name to be called, and the target synchronization processing function RpcProcedure is looked up in the global dictionary Dict according to the method name.
  • the execution unit 24 is configured to execute the target synchronization processing function in the asynchronous thread, and acquire and send the execution result.
  • the execution unit 24 obtains the parameter list from the RpcMessage message; specifically, the IRpcArgument structure is obtained from the RpcMessage message by calling the GetRpcArgsFromMessage function, and then called.
  • the parameter obtaining method i32Value in the IRpcArgument structure acquires parameter information in the target calling request.
  • the execution unit 24 After obtaining all the parameter information, the execution unit 24 also needs to acquire an identifier in the target call request, where the identifier is a unique identifier of the target call request, and is used to distinguish from other call requests, to avoid Confusion; it should be noted that there is a unique identifier for each invocation request.
  • the calling end calls the RpcCallProcedure function to send the target call request by the calling end
  • an identifier is generated, and the identifier is written into the gid field of the RpcMessage message
  • the called end receives the RpcMessage message
  • the The execution unit 24 can obtain the identifier in the target call request from the gid field.
  • the execution unit 24 delivers the target synchronization processing function to the asynchronous thread, where the execution is performed in the asynchronous thread.
  • the target synchronization processing function RpcProcedure is obtained to obtain an execution result.
  • the execution unit 24 calls CreateRpcArgumentArray to create an IRpcArgumentArray, and then calls the append method of the IRpcArgumentArray to put the execution result into the IRDcArgumentArray.
  • the execution unit 24 further serializes the identifier and the execution result into a network message, and sends the network message to the calling end.
  • the first value is ERROR_OK, which is used to inform the calling end that the remote call is successful; the first value is IRpcArgumentArray.
  • the execution unit 24 calls the BuildRpcMessageFrom method to serialize the result set into a network message, and sets the gid field in the network message as an identifier, and sets the rpcType field in the network message to an RPC_MESSAGE_RESPONSE value for indicating the network message. Is a remote response message.
  • the execution unit 24 is further configured to: return a result set, where the result set includes an indication value for indicating no search result, and the content of the indication value For ERROR_RPC_NOT_FOUND, it is used to inform the caller that the called process does not have the remote procedure method.
  • the called end calls the RpcRegisterProcedure function before receiving the call request, and registers the name of the pre-scheduled add remote method and the corresponding synchronization processing function in the global dictionary Dict, so that when the call request is received, the global dictionary Dict can be directly used. Find the synchronization processing function corresponding to the add remote method, quickly build a remote procedure call model, and improve processing efficiency.
  • the model of the synchronization processing function is: IRpcArgumentArray*(*RpcProcedure)(void*caller, IRpcArgument**args, int numArgs); wherein the IRpcArgumentArray is an array collection of an IRpcArgument structure for storing the execution result
  • the IRpcArgument is an array structure; the caller, IRpcArgument is an identification parameter; the args is parameter information in the target call request; and the numArgs is the number of the args parameter.
  • the caller will provide two parameters: the first parameter is the value 1, the second parameter is the value 2, then the parameter information is the value 1 and the value 2, and the value of numArgs is Is 2.
  • the receiving call end calls the RpcCallProcedure function to call the target call request of the add remote method, and based on the target call request, determines whether the target synchronization processing function corresponding to the add remote method can be found in the global dictionary,
  • the target call request includes information such as the name of the add remote method.
  • the called end After receiving the target call request, that is, when receiving the RpcMessage message, the called end acquires the name of the add remote method, and based on the name, determines whether the target corresponding to the call request can be found in the global dictionary. Synchronous processing function.
  • the procedure field in the RpcMessage message represents the name of the remote method to be called, and the target synchronization processing function RpcProcedure can be found in the global dictionary Dict according to the method name.
  • the parameter information is obtained from the RpcMessage message; specifically, the array structure IRpcArgument is obtained from the RpcMessage message by calling the GetRpcArgsFromMessage function, and then the IRpcArgument structure is called.
  • the parameter acquisition method i32Value in the method uses the i32Value method to obtain the two values, that is, the value obtained by args[0]->i32Value() is 1, and the value obtained by args[1]->i32Value() is 2.
  • the identifier is a unique identifier of the target call request, and is used to distinguish from other call requests to avoid confusion. It should be noted that there is a unique identifier for each call request.
  • the calling end calls the RpcCallProcedure function to send a target call request to the called end
  • an identifier is generated, and the identifier is written into the gid field of the RpcMessage message, and when the called end receives the RpcMessage message,
  • the identifier in the target call request can be obtained from the gid field.
  • the target synchronization processing function After the identifier is obtained, all the parameter information obtained in the add remote method is provided to the target synchronization processing function. Specifically, the first identifier is assigned to the identifier parameter caller of the target synchronization processing function, IRpcArgument, and the target is The parameter information 1 and 2 in the call request are assigned to args, and the number 2 of the parameter information is assigned to numArgs; in order to avoid the main thread blocking and improve processing efficiency, the target synchronization processing function is delivered to the asynchronous thread, The target synchronization processing function RpcProcedure is executed in the asynchronous thread, and the parameter is converted into an integer content, that is, the first parameter is converted into a value of 1, the second parameter is converted into a value of 2, and then the add method is executed, that is, the addition operation is performed to be executed. As a result, the execution result is 3, and the execution result is obtained.
  • call CreateRpcArgumentArray to create an IRpcArgumentArray
  • call the append method of IRpcArgumentArray to put the execution result into the IRpcArgumentArray, and put the value 3 of the execution result into the IRpcArgumentArray.
  • the first value is ERROR_OK, which is used to inform the calling end that the remote call is successful; the first value is IRpcArgumentArray.
  • the BuildRpcMessageFrom method is called to serialize the result set of the execution result into a network message, and the gid field in the network message is set as an identifier, and the rpcType field in the network message is set to an RPC_MESSAGE_RESPONSE value, indicating that the network message is a Remote response message.
  • the method further includes: returning a result set, where the result set includes an indication value for indicating no search result, and the content of the indication value is ERROR_RPC_NOT_FOUND can be used to inform the caller that the called end does not have a remote procedure method.
  • the embodiment further provides a remote process call computer device.
  • the computer device includes: a radio frequency (RF) circuit 310, a memory 320, an input unit 330, a display unit 340, and an audio circuit 350. , WiFi module 360, processor 370, and power supply 380 and other components.
  • RF radio frequency
  • FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • the RF circuit 310 can be used for receiving and transmitting signals, and in particular, receiving downlink information of the base station and processing it to the processor 370.
  • RF circuit 310 includes, but is not limited to, at least one amplifier, transceiver, coupler, Low Noise Amplifier (LNA), duplexer, and the like.
  • LNA Low Noise Amplifier
  • the memory 320 can be used to store software programs and modules, and the processor 370 executes various functional applications and data processing of the computer devices by running software programs and modules stored in the memory 320.
  • the memory 320 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function, and the like; the storage data area may store data created according to usage of the computer device, and the like.
  • memory 320 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 330 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the computer device.
  • the input unit 330 may include a touch panel 331 and other input devices 332.
  • the touch panel 331 can collect input operations of the user and drive the corresponding connecting device according to a preset program.
  • the touch panel 331 collects the output information and sends it to the processor 370.
  • the input unit 330 may also include other input devices 332.
  • other input devices 332 may include, but are not limited to, one or more of a touch panel, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 340 can be used to display information input by the user or information provided to the user as well as various menus of the computer device.
  • the display unit 340 can include a display panel 341.
  • the display panel 341 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the touch panel 331 can cover the display panel 341. When the touch panel 331 detects a touch operation on or near the touch panel 331, it transmits to the processor 370 to determine the type of the touch event, and then the processor 370 according to the input event. The type provides a corresponding visual output on display panel 341.
  • the touch panel 331 and the display panel 341 are implemented as two separate components in FIG. 3 to implement input and input functions of the computer device, in some embodiments, the touch panel 331 may be integrated with the display panel 341. Implement the input and output functions of computer equipment.
  • An audio circuit 350, a speaker 351, and a microphone 352 can provide an audio interface between the user and the computer device.
  • the audio circuit 350 can transmit the converted electrical data of the received audio data to the speaker 351, and convert it into a sound signal output by the speaker 351;
  • WiFi is a short-range wireless transmission technology.
  • the computer device can help users to send and receive emails, browse web pages and access streaming media through the WiFi module 360. It provides users with wireless broadband Internet access.
  • FIG. 3 shows the WiFi module 360, it can be understood that it does not belong to the essential configuration of the computer device, and may be omitted as needed within the scope of not changing the essence of the invention.
  • Processor 370 is a control center for computer devices that connects various portions of the entire computer device using various interfaces and lines, by running or executing software programs and/or modules stored in memory 320, and recalling data stored in memory 320. , performing various functions and processing data of the computer device, thereby performing overall monitoring of the computer device.
  • the processor 370 may include one or more processing units; preferably, the processor 370 may integrate an application processor, wherein the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the computer device also includes a power source 380 (such as a power adapter) that powers the various components.
  • a power source 380 such as a power adapter
  • the power source can be logically coupled to the processor 370 via a power management system.
  • the method, device and computer device provided by the remote procedure call of the invention can bring at least the following advantages:
  • the present invention provides a remote procedure call method, apparatus, and computer apparatus, the method comprising: registering a name of a pre-agreed remote method and a corresponding synchronization processing function into a global dictionary; receiving a target call request; Calling the request, determining whether the target synchronization processing function corresponding to the call request can be found in the global dictionary; if the target synchronization processing function can be found in the global dictionary, performing the target synchronization in the asynchronous thread
  • the processing function acquires and sends the execution result; thus, the called end can synchronously respond to the call request from the calling end, and only needs to register the synchronization processing function into the global dictionary before receiving the target calling request, after receiving the target calling request According to the call request, a signal path of a remote procedure call can be quickly established, and then the synchronization processing function is executed, and the execution result is returned to the calling end, thereby improving work efficiency.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some, or all, of the gateways, proxy servers, systems in accordance with embodiments of the present invention.
  • DSP digital signal processor
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • Such a program implementing the present invention may be stored on a computer readable storage medium or may be in the form of one or more signals.
  • Such signals may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form; when executed by the processor, the program implements the following steps: the name of the pre-agreed remote method and the corresponding synchronization function.
  • the target synchronization processing function executes the target synchronization processing function in an asynchronous thread to acquire and transmit an execution result.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供了一种远程过程调用的方法、装置及计算机设备,所述方法包括:将预先预定的远程方法的名称及对应的同步处理函数注册至全局字典中;接收目标调用请求;基于所述目标调用请求,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数;若在所述全局字典中能查找到目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果;如此,被调用端可以同步响应来自调用端的调用请求,且只需在接收到目标调用请求之前将同步处理函数注册至全局字典中,在接收到目标调用请求后即可根据所述调用请求快速搭建一个远程过程调用的信号通路,进而执行同步处理函数,向调用端返回执行结果,从而提高了工作效率。

Description

一种远程过程调用的方法、装置及计算机设备 技术领域
本发明属于通信技术领域,尤其涉及一种远程过程调用的方法、装置及计算机设备。
背景技术
远程过程调用,就是一个进程调用另外一个进程所提供的方法,适用于进程间的通信。
现有技术中在远程过程调用中,在处理相应的服务时,需要搭建远程过程调用模型,而搭建远程过程调用模型的过程比较繁琐,导致工作效率下降。
基于此,本发明提供一种远程过程调用的方法、装置及计算机设备,以解决现有技术中的上述问题。
发明内容
针对现有技术存在的问题,本发明实施例提供了一种远程过程调用的方法、装置及计算机设备,用于解决现有技术中在进行远程过程调用时,搭建远程过程调用模型的过程比较繁琐,导致工作效率下降的技术问题。
本发明提供一种远程过程调用的方法,所述方法包括:
将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
接收目标调用请求;
基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数;
若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
上述方案中,所述若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,包括:
获取所述目标调用请求中的参数信息;
基于所述参数信息,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数。
上述方案中,所述获取并发送执行结果,包括:
获取所述目标调用请求中的标识符;
将所述标识符及所述执行结果序列化为一个网络消息,发送所述网络消 息。
上述方案中,所述将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中,包括:
调用RpcRegisterProcedure函数,将预先约定的远程方法的名称及所述远程方法对应的同步处理函数注册至全局字典中。
上述方案中,若在所述全局字典中没有查找到目标同步处理函数,还包括:
返回结果集,所述结果集中包括用于指示无查找结果的指示值。
上述方案中,所述同步处理函数具体为:IRpcArgumentArray*(*RpcProcedure)(void*caller,IRpcArgument**args,int numArgs);其中,所述IRpcArgumentArray为数组集合,用于存储所述执行结果;所述args为所述目标调用请求中的参数信息;所述numArgs为所述args参数的个数。
本发明还提供一种远程过程调用的装置,所述装置包括:
注册单元,用于将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
接收单元,用于接收目标调用请求;
判断单元,用于基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的所述目标同步处理函数;
执行单元,用于若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
上述方案中,所述执行单元具体用于:
获取所述目标调用请求中的参数信息;
基于所述参数信息,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数。
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:
将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
接收目标调用请求;
基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数;
若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
本发明还提供一种远程过程调用的计算机设备,包括:
至少一个处理器;以及
与所述处理器通信连接的至少一个存储器,其中,
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如上述任一所述的方法。
本发明提供了一种远程过程调用的方法、装置及计算机设备,所述方法包括:将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;接收目标调用请求;基于所述目标调用请求,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数;若在所述全局字典中能查找到目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果;如此,被调用端可以同步响应来自调用端的调用请求,且只需在接收到目标调用请求之前将同步处理函数注册至全局字典中,在接收到目标调用请求后即可根据所述调用请求快速搭建一个远程过程调用的信号通路,进而执行同步处理函数,向调用端返回执行结果,从而提高了工作效率。
附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1为本发明实施例一提供的远程过程调用的方法流程示意图;
图2为本发明实施例二提供的远程过程调用的装置结构示意图;
图3为本发明实施例三提供的远程过程调用的计算机设备的整体结构示意图。
具体实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
实施例一
本实施例提供一种远程过程调用的方法,如图1所示,所述方法包括:
S101,将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
本步骤中,在接收调用请求之前,需要调用RpcRegisterProcedure函数,将预先约定的远程方法的名称及该远程方法对应的同步处理函数注册至全局字典Dict中,以能在接收到调用请求时,可以直接在全局字典Dict中查找相应的 同步处理函数,快速搭建远程过程调用模型,提高处理效率。所述预先约定的远程方法为调用端与被调用端预先约定的。
这里,所述同步处理函数的模型为:IRpcArgumentArray*(*RpcProcedure)(void*caller,IRpcArgument**args,int numArgs);其中,所述IRpcArgumentArray为IRpcArgument结构的数组集合,用于存储所述执行结果;所述caller,IRpcArgument为标识参数;所述args为所述目标调用请求中的参数信息;所述numArgs为所述args参数的个数。
S102,接收目标调用请求,基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数;
本步骤中,将预先约定的远程方法对应的同步处理函数注册至全局字典Dict中后,接收调用端通过调用RpcCallProcedure函数发送的目标调用请求,基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数。其中,所述目标调用请求中包括预先约定的远程方法的名称等信息。
具体地,接收目标调用请求后,也就是接收到RpcMessage消息时,获取远程方法的名称,基于所述名称,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数。这里,RpcMessage消息中的procedure字段代表要调用的远程方法名,根据该方法名在全局字典Dict中查找目标同步处理函数RpcProcedure。
S103,若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
本步骤中,如果能在所述全局字典中查找到目标同步处理函数RpcProcedure,则从RpcMessage消息中获取参数信息;具体是通过调用GetRpcArgsFromMessage函数从RpcMessage消息中获取到IRpcArgument结构,然后调用IRpcArgument结构中的参数获取方法i32Value,获取所述目标调用请求中的参数信息。
当获取到所有的参数信息后,还需要获取所述目标调用请求中的标识符,所述标识符是目标调用请求的唯一标识符,用于与其他调用请求进行区分,避免混淆;需要说明的是,每个调用请求都会存在一个唯一的标识符。
具体地,当调用端调用RpcCallProcedure函数向被调用端发送目标调用请求时,会生成一个标识符,并将这个标识符写入RpcMessage消息中gid字段中,当被调用端接收到RpcMessage消息后,即可从gid字段获取所述目标调用请求中的标识符。
当获取到标识符后,将所有的参数信息提供给目标同步处理函数,具体地, 将第一标识符赋值给所述目标同步处理函数的标识参数caller,IRpcArgument,将目标调用请求中的参数信息赋值给args,将参数信息的个数赋值给numArgs;为了避免主线程阻塞,提高处理效率,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数RpcProcedure,获取执行结果。
当获取到执行结果后,调用CreateRpcArgumentArray创建一个IRpcArgumentArray,然后调用IRpcArgumentArray的append方法将执行结果放入IRpcArgumentArray中。
再将所述标识符及所述执行结果序列化为一个网络消息,将所述述网络消息发送至调用端。
具体地,当同步处理函数执行成功后,在执行结果的结果集中,第一个值为ERROR_OK,用于告知调用端,本次远程调用成功;第一个值后即是IRpcArgumentArray。
然后,调用BuildRpcMessageFrom方法将执行结果的结果集序列化成一个网络消息,并将网络消息中的gid字段设置为标识符,将网络消息中的rpcType字段设置为RPC_MESSAGE_RESPONSE值,用于表示该网络消息是一个远程响应消息。
另外,若在全局字典Dict中没有查找到目标同步处理函数,还包括:返回结果集,所述结果集中包括用于指示无查找结果的指示值,所述指示值的内容为可以ERROR_RPC_NOT_FOUND,用于告知调用端,被调用端没有该远程过程方法。
实施例二
相应于实施例一,本实施例还提供一种远程过程调用的装置,如图2所示,所述远程过程调用装置包括:注册单元21、接收单元22、判断单元23及执行单元24;其中,
在接收调用请求之前,所述注册单元21需要调用RpcRegisterProcedure函数,将预先约定的远程方法的名称及该远程方法对应的同步处理函数注册至全局字典Dict中,以能在接收到调用请求时,可以直接在全局字典Dict中查找相应的同步处理函数,快速搭建远程过程调用模型,提高处理效率。所述预先约定的远程方法为调用端与被调用端预先约定的。
这里,所述同步处理函数的模型为:IRpcArgumentArray*(*RpcProcedure)(void*caller,IRpcArgument**args,int numArgs);其中,所述IRpcArgumentArray为IRpcArgument结构的数组集合,用于存储所述执行结果;所述caller,IRpcArgument为标识参数;所述args为所述目标调用请求中的参数 信息;所述numArgs为所述args参数的个数。
所述注册单元21将预先约定的远程方法对应的同步处理函数注册至全局字典Dict中后,所述接收单元22用于接收调用端调用RpcCallProcedure函数发送的目标调用请求,基于所述目标调用请求,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数。其中,所述目标调用请求中包括预先约定的远程方法的名称等信息。
具体地,所述接收单元22接收目标调用请求后,也就是接收到RpcMessage消息时,获取远程方法的名称,判断单元23可以基于所述名称,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数。这里,RpcMessage消息中的procedure字段代表要调用的远程方法名,根据该方法名在全局字典Dict中查找目标同步处理函数RpcProcedure。
若在所述全局字典中能查找到目标同步处理函数,所述执行单24用于在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
具体地,如果能在所述全局字典中查找到目标同步处理函数RpcProcedure,所述执行单元24则从RpcMessage消息中获取参数列表;具体是通过调用GetRpcArgsFromMessage函数从RpcMessage消息中获取到IRpcArgument结构,然后调用IRpcArgument结构中的参数获取方法i32Value,获取所述目标调用请求中的参数信息。
当获取到所有的参数信息后,所述执行单元24还需要获取所述目标调用请求中的标识符,所述标识符是目标调用请求的唯一标识符,用于与其他调用请求进行区分,避免混淆;需要说明的是,每个调用请求都会存在一个唯一的标识符。
具体地,当调用端调用RpcCallProcedure函数想被调用端发送目标调用请求时,会生成一个标识符,并将这个标识符写入RpcMessage消息中gid字段中,当被调用端接收到RpcMessage消息后,所述执行单元24即可从gid字段获取所述目标调用请求中的标识符。
当获取到标识符后,将所有的参数信息提供给目标同步处理函数,具体地,将第一标识符赋值给所述目标同步处理函数的标识参数caller,IRpcArgument,将目标调用请求中的参数信息赋值给args,将参数信息的个数赋值给numArgs;为了避免主线程阻塞,提高处理效率,所述执行单元24将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数RpcProcedure,获取执行结果。
当获取到执行结果后,所述执行单元24调用CreateRpcArgumentArray创建一个IRpcArgumentArray,然后调用IRpcArgumentArray的append方法将执行结 果放入IRDcArgumentArray中。
所述执行单元24再将所述标识符及所述执行结果序列化为一个网络消息,将所述述网络消息发送至调用端。
具体地,当同步处理函数执行成功后,在执行结果的结果集中,第一个值为ERROR_OK,用于告知调用端,本次远程调用成功;第一个值后即是IRpcArgumentArray。
然后,所述执行单元24调用BuildRpcMessageFrom方法将结果集序列化成一个网络消息,并将网络消息中的gid字段设置为标识符,将网络消息中的rpcType字段设置为RPC_MESSAGE_RESPONSE值,用于表示该网络消息是一个远程响应消息。
另外,若在全局字典Dict中没有查找到目标同步处理函数,所述执行单元24还用于:返回结果集,所述结果集中包括用于指示无查找结果的指示值,所述指示值的内容为可以ERROR_RPC_NOT_FOUND,用于告知调用端,被调用端没有该远程过程方法。
实施例三
实际应用中,利用实施例一提供的调用方法及实施例二提供的调用装置对add远程方法进行调用时,具体实现如下:
被调用端在接收调用请求之前,调用RpcRegisterProcedure函数,将预先预定的add远程方法的名称及对应的同步处理函数注册至全局字典Dict中,以能在接收到调用请求时,可以直接在全局字典Dict中查找add远程方法对应的同步处理函数,快速搭建远程过程调用模型,提高处理效率。
这里,所述同步处理函数的模型为:IRpcArgumentArray*(*RpcProcedure)(void*caller,IRpcArgument**args,int numArgs);其中,所述IRpcArgumentArray为IRpcArgument结构的数组集合,用于存储所述执行结果;所述IRpcArgument为数组结构;所述caller,IRpcArgument为标识参数;所述args为所述目标调用请求中的参数信息;所述numArgs为所述args参数的个数。比如,在调用add远程方法时,调用端将提供两个参数:第一个参数是数值1,第二个参数是数值2,那么,参数信息即为数值1和数值2,而numArgs的值则为2。
然后,接收调用端通过调用RpcCallProcedure函数发送的调用add远程方法的目标调用请求,基于所述目标调用请求,判断在所述全局字典中是否能查找到所述add远程方法对应的目标同步处理函数,所述目标调用请求中包括add远程方法的名称等信息。
具体地,被调用端接收目标调用请求后,也就是接收到RpcMessage消息时,获取add远程方法的名称,基于所述名称,判断在所述全局字典中是否能 查找到所述调用请求对应的目标同步处理函数。这里,RpcMessage消息中的procedure字段代表要调用的远程方法名称,可以根据该方法名在全局字典Dict中查找目标同步处理函数RpcProcedure。
如果能在所述全局字典中查找到add远程方法对应的目标同步处理函数RpcProcedure,则从RpcMessage消息中获取参数信息;具体是通过调用GetRpcArgsFromMessage函数从RpcMessage消息中获取到数组结构IRpcArgument,然后调用IRpcArgument结构中的参数获取方法i32Value,利用i32Value方法,来获取这两个数值,即args[0]->i32Value()获取的值就是1,args[1]->i32Value()获取的值就是2。
当获取到add远程方法的所有的参数信息后,还需要获取所述目标调用请求中的标识符,所述标识符是目标调用请求的唯一标识符,用于与其他调用请求进行区分,避免混淆;需要说明的是,每个调用请求都会存在一个唯一的标识符。
具体地,当调用端调用RpcCallProcedure函数向被调用端发送目标调用请求时,会生成一个标识符,并将这个标识符写入RpcMessage消息中gid字段中,当被调用端接收到RpcMessage消息后,即可从gid字段获取所述目标调用请求中的标识符。
当获取到标识符后,将获取到add远程方法中所有的参数信息提供给目标同步处理函数,具体地,将第一标识符赋值给所述目标同步处理函数的标识参数caller,IRpcArgument,将目标调用请求中的参数信息1和2赋值给args,将参数信息的个数2赋值给numArgs;为了避免主线程阻塞,提高处理效率,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数RpcProcedure,将参数转换为整数内容,即将第一个参数转换为数值1,将第二个参数转换为数值2,然后执行add方法,即执行加法运算得到执行结果,即执行结果为3,获取执行结果。
当获取到执行结果后,调用CreateRpcArgumentArray创建一个IRpcArgumentArray,然后调用IRpcArgumentArray的append方法将执行结果放入IRpcArgumentArray中,即将执行结果的数值3放入IRpcArgumentArray中。
再将上述所述的标识符及所述执行结果序列化为一个网络消息,将所述述网络消息发送至调用端。
具体地,当同步处理函数执行成功后,在执行结果的结果集中,第一个值为ERROR_OK,用于告知调用端,本次远程调用成功;第一个值后即是IRpcArgumentArray。
然后,调用BuildRpcMessageFrom方法将执行结果的结果集序列化成一个 网络消息,并将网络消息中的gid字段设置为标识符,将网络消息中的rpcType字段设置为RPC_MESSAGE_RESPONSE值,用于表示该网络消息是一个远程响应消息。
另外,若在全局字典Dict中没有查找到add远程方法对应的目标同步处理函数,还包括:返回结果集,所述结果集中包括用于指示无查找结果的指示值,所述指示值的内容为可以ERROR_RPC_NOT_FOUND,用于告知调用端,被调用端没有add远程过程方法。
实施例四
本实施例还提供一种远程过程调用的计算机设备,如图3所示,所述计算机设备包括:射频(Radio Frequency,RF)电路310、存储器320、输入单元330、显示单元340、音频电路350、WiFi模块360、处理器370、以及电源380等部件。本领域技术人员可以理解,图3中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
下面结合图3对计算机设备的各个构成部件进行具体的介绍:
RF电路310可用于信号的接收和发送,特别地,将基站的下行信息接收后,给处理器370处理。通常,RF电路310包括但不限于至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。
存储器320可用于存储软件程序以及模块,处理器370通过运行存储在存储器320的软件程序以及模块,从而执行计算机设备的各种功能应用以及数据处理。存储器320可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据计算机设备的使用所创建的数据等。此外,存储器320可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元330可用于接收输入的数字或字符信息,以及产生与计算机设备的用户设置以及功能控制有关的键信号输入。具体地,输入单元330可包括触控面板331以及其他输入设备332。触控面板331,可收集用户在其上的输入操作,并根据预先设定的程式驱动相应的连接装置。触控面板331采集到输出信息后再送给处理器370。除了触控面板331,输入单元330还可以包括其他输入设备332。具体地,其他输入设备332可以包括但不限于触控面板、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元340可用于显示由用户输入的信息或提供给用户的信息以及计算机设备的各种菜单。显示单元340可包括显示面板341,可选的,可以采用液晶 显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板341。进一步的,触控面板331可覆盖显示面板341,当触控面板331检测到在其上或附近的触摸操作后,传送给处理器370以确定触摸事件的类型,随后处理器370根据输入事件的类型在显示面板341上提供相应的视觉输出。虽然在图3中触控面板331与显示面板341是作为两个独立的部件来实现计算机设备的输入和输入功能,但是在某些实施例中,可以将触控面板331与显示面板341集成而实现计算机设备的输入和输出功能。
音频电路350、扬声器351,传声器352可提供用户与计算机设备之间的音频接口。音频电路350可将接收到的音频数据转换后的电信号,传输到扬声器351,由扬声器351转换为声音信号输出;
WiFi属于短距离无线传输技术,计算机设备通过WiFi模块360可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图3示出了WiFi模块360,但是可以理解的是,其并不属于计算机设备的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。
处理器370是计算机设备的控制中心,利用各种接口和线路连接整个计算机设备的各个部分,通过运行或执行存储在存储器320内的软件程序和/或模块,以及调用存储在存储器320内的数据,执行计算机设备的各种功能和处理数据,从而对计算机设备进行整体监控。可选的,处理器370可包括一个或多个处理单元;优选的,处理器370可集成应用处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等。
计算机设备还包括给各个部件供电的电源380(比如电源适配器),优选的,电源可以通过电源管理系统与处理器370逻辑相连。
本发明提供的远程过程调用的方法、装置及计算机设备能带来的有益效果至少是:
本发明提供一种远程过程调用的方法、装置及计算机设备,所述方法包括:将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;接收目标调用请求;基于所述目标调用请求,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数;若在所述全局字典中能查找到目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果;如此,被调用端可以同步响应来自调用端的调用请求,且只需在接收到目标调用请求之前将同步处理函数注册至全局字典中,在接收到目标调用请求后即可根据所述调用请求快速搭建一个远程过程调用的信号通路,进而执行同步处理函数,向调用端返回执行结果,从而提高了工作效率。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有 相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的网关、代理服务器、系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程 序可以存储在计算机可读存储介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供;该程序被处理器执行时实现以下步骤:将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;接收目标调用请求;基于所述目标调用请求,判断在所述全局字典中是否能查找到所述调用请求对应的目标同步处理函数;若在所述全局字典中能查找到目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种远程过程调用的方法,其特征在于,所述方法包括:
    将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
    接收目标调用请求;
    基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数;
    若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
  2. 如权利要求1所述的方法,其特征在于,所述若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,包括:
    获取所述目标调用请求中的参数信息;
    基于所述参数信息,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数。
  3. 如权利要求1所述的方法,其特征在于,所述获取并发送执行结果,包括:
    获取所述目标调用请求中的标识符;
    将所述标识符及所述执行结果序列化为一个网络消息,发送所述网络消息。
  4. 如权利要求1所述的方法,其特征在于,所述将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中,包括:
    调用RpcRegisterProcedure函数,将预先约定的远程方法的名称及所述远程方法对应的同步处理函数注册至全局字典中。
  5. 如权利要求1所述的方法,其特征在于,若在所述全局字典中没有查找到目标同步处理函数,还包括:
    返回结果集,所述结果集中包括用于指示无查找结果的指示值。
  6. 如权利要求1所述的方法,其特征在于,所述同步处理函数具体为:IRpcArgumentArray*(*RpcProcedure)(void*caller,IRpcArgument**args,int numArgs);其中,所述IRpcArgumentArray为数组集合,用于存储所述执行结果;所述args为所述目标调用请求中的参数信息;所述numArgs为所述args参数的个数。
  7. 一种远程过程调用的装置,其特征在于,所述装置包括:
    注册单元,用于将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
    接收单元,用于接收目标调用请求;
    判断单元,用于基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的所述目标同步处理函数;
    执行单元,用于若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
  8. 如权利要求7所述的装置,其特征在于,所述执行单元具体用于:
    获取所述目标调用请求中的参数信息;
    基于所述参数信息,将所述目标同步处理函数投递至异步线程中,在所述异步线程中执行所述目标同步处理函数。
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现以下步骤:
    将预先约定的远程方法的名称及对应的同步处理函数注册至全局字典中;
    接收目标调用请求;
    基于所述目标调用请求,判断在所述全局字典中是否能查找到所述目标调用请求对应的目标同步处理函数;
    若在所述全局字典中能查找到所述目标同步处理函数,则在异步线程中执行所述目标同步处理函数,获取并发送执行结果。
  10. 一种远程过程调用的计算机设备,其特征在于,包括:
    至少一个处理器;以及
    与所述处理器通信连接的至少一个存储器,其中,
    所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如权利要求1至6任一所述的方法。
PCT/CN2018/082162 2017-06-30 2018-04-08 一种远程过程调用的方法、装置及计算机设备 Ceased WO2019001073A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710523205.1 2017-06-30
CN201710523205.1A CN107479985B (zh) 2017-06-30 2017-06-30 一种远程过程调用的方法、装置及计算机设备

Publications (1)

Publication Number Publication Date
WO2019001073A1 true WO2019001073A1 (zh) 2019-01-03

Family

ID=60594848

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082162 Ceased WO2019001073A1 (zh) 2017-06-30 2018-04-08 一种远程过程调用的方法、装置及计算机设备

Country Status (2)

Country Link
CN (1) CN107479985B (zh)
WO (1) WO2019001073A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107479985B (zh) * 2017-06-30 2020-01-03 武汉斗鱼网络科技有限公司 一种远程过程调用的方法、装置及计算机设备
CN110245027B (zh) * 2018-09-21 2024-05-14 浙江大华技术股份有限公司 一种进程间通信的方法和设备
CN114461291A (zh) * 2020-10-22 2022-05-10 北京国双科技有限公司 应用程序组件调用方法、装置、电子设备及存储介质
CN112328410B (zh) * 2020-11-04 2023-08-08 网易(杭州)网络有限公司 远程过程调用的实现方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1635485A (zh) * 2003-12-26 2005-07-06 华为技术有限公司 远程同步调用过程中的超时自适应方法
CN101697139A (zh) * 2009-11-06 2010-04-21 金蝶软件(中国)有限公司 一种远程过程调用方法、装置和注册库
CN103442075A (zh) * 2013-09-04 2013-12-11 珠海金山网络游戏科技有限公司 一种远程调用的方法
US20150143339A1 (en) * 2013-11-19 2015-05-21 Google Inc. Callpath finder
CN106161537A (zh) * 2015-04-10 2016-11-23 阿里巴巴集团控股有限公司 远程过程调用的处理方法、装置、系统及电子设备
CN107479985A (zh) * 2017-06-30 2017-12-15 武汉斗鱼网络科技有限公司 一种远程过程调用的方法、装置及计算机设备

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104220984B (zh) * 2012-04-06 2018-04-24 索尼公司 信息处理装置、信息处理方法、以及计算机程序

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1635485A (zh) * 2003-12-26 2005-07-06 华为技术有限公司 远程同步调用过程中的超时自适应方法
CN101697139A (zh) * 2009-11-06 2010-04-21 金蝶软件(中国)有限公司 一种远程过程调用方法、装置和注册库
CN103442075A (zh) * 2013-09-04 2013-12-11 珠海金山网络游戏科技有限公司 一种远程调用的方法
US20150143339A1 (en) * 2013-11-19 2015-05-21 Google Inc. Callpath finder
CN106161537A (zh) * 2015-04-10 2016-11-23 阿里巴巴集团控股有限公司 远程过程调用的处理方法、装置、系统及电子设备
CN107479985A (zh) * 2017-06-30 2017-12-15 武汉斗鱼网络科技有限公司 一种远程过程调用的方法、装置及计算机设备

Also Published As

Publication number Publication date
CN107479985B (zh) 2020-01-03
CN107479985A (zh) 2017-12-15

Similar Documents

Publication Publication Date Title
WO2019001074A1 (zh) 一种远程过程调用的方法、装置及计算机设备
EP3389230B1 (en) System for providing dialog content
CN108280014B (zh) 一种监听浏览器页面的方法、装置及计算机设备
CN105337787A (zh) 一种多服务器监控方法、装置和系统
CN105471931B (zh) 一种查询业务数据的方法、装置和系统
CN107204964B (zh) 一种权限管理的方法、装置和系统
WO2018170833A1 (zh) 一种上行数据传输方法、终端、网络侧设备及系统
WO2019001073A1 (zh) 一种远程过程调用的方法、装置及计算机设备
JP2018504708A (ja) 情報の推薦を管理するための方法、デバイス、およびシステム
CN103678605A (zh) 一种信息传输的方法、装置及终端设备
WO2017096909A1 (zh) 建立数据连接的方法及装置
WO2017219293A1 (zh) 一种获取网页内容的方法及装置
KR20210044281A (ko) 클라우드 저하 모드에서 지속적인 디바이스 동작 안정성을 보장하기 위한 방법 및 장치
WO2018086454A1 (zh) 页面数据处理方法和装置
WO2015062234A1 (zh) 移动终端资源处理方法、装置和设备
CN107610036B (zh) 一种输出直播标识图片的方法、装置及计算机设备
WO2017166093A1 (zh) 前置系统
CN112732548B (zh) 一种接口测试方法以及装置
CN108234663B (zh) 一种获取数据的方法、装置及计算机设备
WO2019134288A1 (zh) 一种用于实现视图控制器的方法、装置及计算机设备
CN114189436B (zh) 一种多集群配置部署方法、装置、电子设备和存储介质
CN112799857A (zh) 一种应用访问方法以及装置
TWI815098B (zh) Web請求處理方法、裝置、電子設備以及內儲程式之電腦可讀取記錄媒體
CN109379394A (zh) 一种监控网络请求的方法、装置及终端
WO2019140565A1 (zh) 云存储命令管理方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18823237

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18823237

Country of ref document: EP

Kind code of ref document: A1