CN110704203B - Interruptible remote procedure calling method and interruptible remote procedure calling device - Google Patents

Interruptible remote procedure calling method and interruptible remote procedure calling device Download PDF

Info

Publication number
CN110704203B
CN110704203B CN201810750589.5A CN201810750589A CN110704203B CN 110704203 B CN110704203 B CN 110704203B CN 201810750589 A CN201810750589 A CN 201810750589A CN 110704203 B CN110704203 B CN 110704203B
Authority
CN
China
Prior art keywords
remote procedure
procedure call
call
result
return
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.)
Active
Application number
CN201810750589.5A
Other languages
Chinese (zh)
Other versions
CN110704203A (en
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.)
Aerospace Guosheng 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
Priority to CN201810750589.5A priority Critical patent/CN110704203B/en
Publication of CN110704203A publication Critical patent/CN110704203A/en
Application granted granted Critical
Publication of CN110704203B publication Critical patent/CN110704203B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/547Remote procedure calls [RPC]; Web services

Abstract

The invention discloses an interruptible remote procedure calling method and a device, wherein the method comprises the following steps: if the remote procedure call is synchronous call and interruptible, judging whether the waiting time is less than preset timeout time; if the waiting time is not less than the preset overtime, ending the remote procedure call; if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function; if the return value of the interrupt function is true, ending the remote procedure call; if the return value of the interrupt function is not true, judging whether a return result of the called end is received; if the return result of the called end is received, the remote procedure call is ended; and if the return result of the called end is not received, continuing to execute the judgment of whether the waiting time is less than the preset time. The remote procedure call can be ended by setting an interrupt function before a call result is received or the call is overtime, so that the current thread is in a runnable state.

Description

Interruptible remote procedure calling method and interruptible remote procedure calling device
Technical Field
The invention relates to the technical field of computers, in particular to an interruptible remote procedure calling method and device.
Background
A Remote Procedure Call (RPC) is a process that calls a method provided by another process, but the Call side is still consistent with the function calling the process. In the remote procedure call, all parameters to be provided to the called end process are serialized into a network message and then sent to the called end process through network transmission. After the called end completes the corresponding service, the generated result is also serialized into a network message and sent to the calling end process.
In the implementation of the RPC, if the RPC service function of the counterpart program is called in a synchronous manner, the current thread is blocked, and the current thread cannot continue to execute until the response of the counterpart program reaches or the call times out. Therefore, when the RPC is called in a synchronous manner in the main thread with the graphical interface, the main thread of the program is blocked, so that any interface message, including mouse click, keyboard message, etc., cannot be responded, thereby causing the program to be jammed.
Disclosure of Invention
The invention provides an interruptible remote procedure calling method and device, and solves the problem that in the prior art, a current thread can be continuously executed only when a calling result or calling overtime exists in a synchronous calling process of a remote procedure.
In a first aspect, an embodiment of the present invention provides an interruptible remote procedure call method, where the method includes:
judging whether the remote procedure call is a synchronous call;
if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not;
if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time;
if the waiting time is not less than the preset overtime time, ending the remote procedure call;
if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function;
if the return value of the interrupt function is true, ending the remote procedure call;
if the return value of the interrupt function is not true, judging whether a return result of the called end is received;
if the return result of the called end is received, ending the remote procedure call;
and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset time.
Optionally, the determining whether the remote procedure call is a synchronous call includes:
judging whether the remote procedure CALL is a synchronous CALL or not according to the value of an RPC _ ATTR _ ASYNC _ CALL attribute, wherein the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting a calling mode;
if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 0, determining that the remote procedure CALL is a synchronous CALL;
and if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 1, determining that the remote procedure CALL is an asynchronous CALL.
Optionally, the determining whether the remote procedure call is set to be interruptible includes:
registering the interrupt CALLBACK FUNCTION with the type of RPC _ POLL _ TASK by setting an RPC _ ATTR _ CALLBACK _ FUNCTION attribute, wherein the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is used for setting the CALLBACK FUNCTION in the FUNCTION;
judging whether the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0 or not;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is not 0, determining that the remote procedure call is set to be interruptible;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0, determining that the remote procedure call is set to be non-interrupted.
Optionally, after determining whether the remote procedure call is set to be interruptible, the method further includes:
serializing an IRpcArgment type remote procedure call parameter into the remote procedure call message;
creating a remote procedure call message combination structure body, wherein the remote procedure call message combination structure body comprises an rpcMessage field, a mutual exclusion lock member, a condition member and a result member, the mutual exclusion lock member is used for controlling a function not to return, the condition member is used for setting a condition for executing the function, and the result member is used for setting a result returned to a call end;
and storing the remote procedure call message into the rpcMessage field.
Optionally, if the return value of the interrupt function is true, ending the remote procedure call includes:
if the return value of the interrupt function is true, setting a result member of the remote procedure call message combination structure body as ERROR _ INTERRUPTED to represent that the remote procedure call is INTERRUPTED;
and returning the result member as a return value to a calling end, thereby finishing the remote procedure call.
Optionally, if the waiting time is not less than the preset timeout time, ending the remote procedure call includes:
if the waiting time is not less than the preset TIMEOUT time, setting a result member of the remote procedure call message combination structure as ERROR _ TIMEOUT, and indicating that the remote procedure call is TIMEOUT;
and returning the result member as a return value to a calling end, thereby finishing the remote procedure call.
Optionally, after determining whether the remote procedure call is set to be interruptible, the method further includes:
if the remote procedure call is set to be non-interrupted, after the remote procedure call message is sent to the called end, executing non-interrupted synchronous call;
in the non-interrupted synchronous call, calling a timed _ wait method of the conditional member, transmitting the mutex lock member into a first parameter of the timed _ wait method, and transmitting the preset timeout time into a second parameter of the timed _ wait method, so that the timed _ wait method does not return within the preset timeout time;
if the return result of the called end is received within the preset timeout time, calling a signal _ one method of the condition member to trigger the timed _ wait method to return true, indicating that the remote procedure call is not timeout, storing the return result of the called end to the result member and then returning to the calling end, thereby ending the remote procedure call;
if the returned result of the called end is not received within the preset TIMEOUT period, the timed _ wait method returns false, which indicates that the remote procedure call is overtime, and returns to the calling end after the result member is set as ERROR _ TIMEOUT, thereby ending the remote procedure call.
In a second aspect, an embodiment of the present invention provides an interruptible remote procedure call device, where the device includes:
the first judgment unit is used for judging whether the remote procedure call is a synchronous call;
a second determining unit, configured to determine whether the remote procedure call is set to be interruptible if the remote procedure call is a synchronous call;
a third judging unit, configured to, if the remote procedure call is set to be interruptible, judge whether the waiting time is less than a preset timeout after sending the remote procedure call message to the called end;
a first ending unit, configured to end the remote procedure call if the waiting time is not less than the preset timeout time;
a fourth judging unit, configured to judge whether to end the remote procedure call according to a return value of the interrupt function if the waiting time is less than a preset timeout;
a second ending unit, configured to end the remote procedure call if a return value of the interrupt function is true;
a fifth judging unit, configured to judge whether a return result of the called end is received if the return value of the interrupt function is not true;
a third ending unit, configured to end the remote procedure call if a return result of the called end has been received;
and if the return result of the called end is not received, continuing to execute the operation of the third judgment unit.
Optionally, the first determining unit is specifically configured to:
judging whether the remote procedure CALL is a synchronous CALL or not according to the value of an RPC _ ATTR _ ASYNC _ CALL attribute, wherein the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting a calling mode;
if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 0, determining that the remote procedure CALL is a synchronous CALL;
and if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 1, determining that the remote procedure CALL is an asynchronous CALL.
Optionally, the second judging unit is specifically configured to:
registering the interrupt CALLBACK FUNCTION with the type of RPC _ POLL _ TASK by setting an RPC _ ATTR _ CALLBACK _ FUNCTION attribute, wherein the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is used for setting the CALLBACK FUNCTION in the FUNCTION;
judging whether the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0 or not;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is not 0, determining that the remote procedure call is set to be interruptible;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0, determining that the remote procedure call is set to be non-interrupted.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements any implementation of the interruptible remote procedure call method when executing the program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is implemented to implement any implementation of the interruptible remote procedure call method described above when executed by a processor.
In the method, the device, the equipment and the medium provided by the embodiment of the application, whether the remote procedure call is a synchronous call is judged; if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not; if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time; if the waiting time is not less than the preset overtime, ending the remote procedure call; if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function; if the return value of the interrupt function is true, ending the remote procedure call; if the return value of the interrupt function is not true, judging whether a return result of the called end is received; if the return result of the called end is received, ending the remote procedure call; and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset time. The remote procedure call can be ended by setting the interrupt function in the synchronous call of the remote procedure before receiving the call result or calling overtime so as to enable the current thread to be in a runnable state, and the problem that the current thread can be continuously executed only by waiting for the call result or calling overtime in the prior art is solved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow diagram of an interruptible remote procedure call method in an embodiment of the present invention;
FIG. 2 is a block diagram of an interruptible remote procedure call device in an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an electronic device according to an embodiment of the invention;
FIG. 4 is a schematic structural diagram of a storage medium according to an embodiment of the present invention.
Detailed Description
By providing the interruptible remote procedure call method, the interruptible remote procedure call device, the interruptible remote procedure call equipment and the interruptible remote procedure call medium, the remote procedure call can be ended before a call result is received or the call is overtime through setting the value of the interrupt function, and the problem that in the prior art, when the RPC service function of the opposite side program is called in a synchronous mode, the current thread can be continuously executed only after the call result or the call is overtime is solved.
In the RpcAllProduceEx method, a callback function is set by using a function pointer mode of a C language instead, and parameters are set by using an RpcAttribute attribute mode.
The parameters of the rpccallproceureex method include a remote procedure call instance handle, a remote program to be sent, a remote procedure call service name, parameters of the remote procedure call, the number of the parameters, and a second attribute array of int64 type. And acquiring required parameters from the parameters set in the RpcAttribute mode and calling RpcAllProduceEx to realize the RpcAllProduceEx.
Among the parameters set in the form of the rpca attribute, the following attributes are included, but not limited to:
(1) an RPC _ ATTR _ CALLBACK _ FUNCTION attribute for setting the relevant CALLBACK FUNCTION in the rpccall procedure ex FUNCTION.
(2) And the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting whether the calling mode is synchronous calling or asynchronous calling.
(3) An RPC _ ATTR _ TIMEOUT _ VALUE attribute for setting the VALUE of TIMEOUT, if not, the default time is INFINITE, i.e., INFINITE.
Based on the technical scheme, the technical scheme in the embodiment of the application has the following general idea:
judging whether the remote procedure call is a synchronous call; if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not; if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time; if the waiting time is not less than the preset overtime time, ending the remote procedure call; if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function; if the return value of the interrupt function is true, ending the remote procedure call; if the return value of the interrupt function is not true, judging whether a return result of the called end is received; if the return result of the called end is received, ending the remote procedure call; and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset time. The remote procedure call can be ended by setting the interrupt function in the synchronous call of the remote procedure before receiving the call result or calling overtime so as to enable the current thread to be in a runnable state, and the problem that the current thread can be continuously executed only by waiting for the call result or calling overtime in the prior art is solved.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
The present embodiment provides an interruptible remote procedure call method, as shown in fig. 1, including:
and step S101, judging whether the remote procedure call is a synchronous call.
Specifically, whether the remote procedure CALL is a synchronous CALL is judged according to the value of an RPC _ ATTR _ ASYNC _ CALL attribute, wherein the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting a calling mode; if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 0, determining that the remote procedure CALL is a synchronous CALL, and continuing to execute the step S102; if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 1, it is determined that the remote procedure CALL is an asynchronous CALL, and the step S107 is continuously executed. It should be understood that the meaning of the values of all attributes in this embodiment is self-defined, and in some other implementations, other values may be used to represent the same meaning, which is not limited herein.
Step S102, judging whether the remote procedure call is set to be interruptible.
Registering the interrupt CALLBACK FUNCTION with the type of RPC _ POLL _ TASK by setting an RPC _ ATTR _ CALLBACK _ FUNCTION attribute, wherein the prototype of the interrupt CALLBACK FUNCTION is as follows:
typedef bool(*RPC_POLL_TASK)(void*userData)
in this embodiment, when the interrupt callback function returns true, it indicates that an interrupt is required, and at this time, regardless of whether a call result is received or not or whether timeout occurs, the RPC synchronous call is exited; when the interrupt callback function returns false, indicating no interrupt, it continues to wait for the result of the call or times out.
Next, judging whether the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0; if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is not 0, it is determined that the remote procedure call is set to interruptible, an interrupted synchronous call is executed, and step S103 is continued.
If the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0, it is determined that the remote procedure call is set to be uninterrupted, an uninterrupted synchronous call is executed, and step S108 is continuously executed.
After judging whether the remote procedure call is set to be interruptible, before executing an interrupted synchronous call or a non-interrupted synchronous call, serializing all RPC parameters of the IRpcArgment type carried in RpcClAllProcedureEx into a remote procedure call message, namely a structure message with the type of RpcMessage, reconstructing a remote procedure call message combined structure, namely an RpcMessageComponite structure, wherein the RpcAlceEx structure comprises an rpcMessage field, a mutex, a condition member condition and a result member result, the mutex member is used for controlling the function not to return, the condition member is used for setting the condition of function execution, the result member is used for setting the result returned to a calling end, wherein the serialized RpcMessage is stored into the cMessage field of the RcMessageComponite structure, and a mutex object with the type of box is created, the mutex object is assigned to the RpcMatgine structure, and the created as a condition object, assigned to the condition member of the RpcessageComosite structure.
Step S103, after the remote procedure call message is sent to the called end, whether the waiting time is less than the preset overtime time is judged.
Specifically, a variable timeWaited is set to represent the waiting time, a preset TIMEOUT time is obtained by obtaining a VALUE of RPC _ ATTR _ TIMEOUT _ VALUE, and it is determined whether the waiting time is smaller than the preset TIMEOUT time, that is, it is determined whether the VALUE of the variable timeWaited is smaller than the VALUE of RPC _ ATTR _ TIMEOUT _ VALUE. If the waiting time is not less than the preset timeout time, which indicates that the time is out, step S106 is executed. If the waiting time is less than the preset timeout time, which indicates no timeout, step S104 is executed.
And step S104, judging whether to end the remote procedure call according to the return value of the interrupt function.
Specifically, the return value of the interrupt function may be set manually, or may be set by another trigger condition, which is not limited herein. If the return value of the interrupt function is true, indicating that the interrupt is required, step S106 is executed, and if the return value of the interrupt function is not true, indicating that the interrupt is not required, step S105 is executed.
Step S105, determining whether a return result of the called end is received.
If the return result of the called end is received, executing step S106, and if the return result of the called end is not received, continuing to execute step S103, and determining whether the waiting time is less than the preset time until the condition for ending the remote procedure call is triggered.
And step S106, ending the remote procedure call.
Specifically, according to different termination conditions, terminating the remote procedure call includes, but is not limited to, the following three cases:
firstly, if the waiting time is not less than the preset TIMEOUT time, setting a result member of an Rpcessagecomposite structure as ERROR _ TIMEOUT to represent TIMEOUT, and returning the result member as a return value to a calling end, thereby ending the remote procedure call and allowing the current thread to continue to run.
Secondly, if the return value of the interrupt function is true, setting a result member in an RpcessageComosite structure as ERROR _ INTERRUPTED to represent that the remote procedure call is INTERRUPTED, and returning the result member as the return value to a call end, thereby ending the remote procedure call and allowing the current thread to continue to run.
Thirdly, if the return result of the called end is received, analyzing the return result of the called party from the received response message, storing the return result into a result member of the RpcMossageComosite structure, returning the result member as a return value to the calling end, thereby ending the remote procedure call, and the current thread can continue to run.
Step S107, an asynchronous call is executed.
Step S108, executing uninterrupted synchronous calling.
In the non-interrupted synchronous call, the current thread is suspended, and the current thread can not continue to execute until the response of the opposite program reaches or the call is overtime.
Specifically, if the remote procedure call is set to non-interrupt, after sending the remote procedure call message to the called end, executing a non-interrupt synchronous call in which a timed _ wait method of a conditional member of the RpcMessageComposite structure is called, the mutex member is transferred to a first parameter of the timed _ wait method, and the preset TIMEOUT time is transferred to a second parameter of the timed _ wait method, so that the timed _ wait method does not return within the preset TIMEOUT time, and the current thread is suspended, wherein the preset TIMEOUT time is obtained by obtaining a VALUE of RPC _ ATTR _ TIMEOUT _ VALUE;
if the return result of the called end is received within the preset timeout time, calling a signal _ one method of the condition member condition to trigger the timed _ wait method to return true, indicating that the remote procedure call is not overtime, storing the return result of the called end into a result member and then returning to the calling end, thereby ending the remote procedure call and continuously executing the current thread;
if the return result of the called end is not received within the preset TIMEOUT time, the timed _ wait method returns false, which indicates that the remote procedure call is overtime, and returns to the calling end after the result member is set as ERROR _ TIMEOUT, so that the remote procedure call is ended, and the current thread can be continuously executed.
In the embodiment, whether the remote procedure call is synchronous call is judged; if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not; if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time; if the waiting time is not less than the preset overtime time, ending the remote procedure call; if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function; if the return value of the interrupt function is true, ending the remote procedure call; if the return value of the interrupt function is not true, judging whether a return result of the called end is received; if the return result of the called end is received, ending the remote procedure call; and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset time. The remote procedure call can be ended by setting the interrupt function in the synchronous call of the remote procedure before receiving the call result or calling overtime so as to enable the current thread to be in a runnable state, and the problem that the current thread can be continuously executed only by waiting for the call result or calling overtime in the prior art is solved.
Based on the same inventive concept, the embodiment of the present invention further provides a device corresponding to the interruptible remote procedure call in the first embodiment, which is shown in the second embodiment.
Example two
The present embodiment provides an interruptible remote procedure call device, as shown in fig. 3, comprising:
a first judging unit 201, configured to judge whether the remote procedure call is a synchronous call;
a second determining unit 202, configured to determine whether the remote procedure call is set to be interruptible if the remote procedure call is a synchronous call;
a third determining unit 203, configured to determine whether the waiting time is less than a preset timeout time after sending the remote procedure call message to the called end if the remote procedure call is set to be interruptible;
a first ending unit 204, configured to end the remote procedure call if the waiting time is not less than the preset timeout time;
a fourth determining unit 205, configured to determine whether to end the remote procedure call according to a return value of the interrupt function if the waiting time is less than a preset timeout;
a second ending unit 206, configured to end the remote procedure call if the return value of the interrupt function is true;
a fifth determining unit 207, configured to determine whether a return result of the called end is received if the return value of the interrupt function is not true;
a third ending unit 208, configured to end the remote procedure call if a return result of the called end has been received;
if the return result of the called end is not received, the operation of the third determining unit 203 is continuously executed.
Optionally, the first determining unit is specifically configured to:
judging whether the remote procedure CALL is a synchronous CALL or not according to the value of an RPC _ ATTR _ ASYNC _ CALL attribute, wherein the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting a calling mode;
if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 0, determining that the remote procedure CALL is a synchronous CALL;
and if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 1, determining that the remote procedure CALL is an asynchronous CALL.
Optionally, the second judging unit is specifically configured to:
registering the interrupt CALLBACK FUNCTION with the type of RPC _ POLL _ TASK by setting an RPC _ ATTR _ CALLBACK _ FUNCTION attribute, wherein the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is used for setting the CALLBACK FUNCTION in the FUNCTION;
judging whether the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0 or not;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is not 0, determining that the remote procedure call is set to be interruptible;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0, determining that the remote procedure call is set to be uninterrupted.
In the embodiment of the present application, the apparatus may be an electronic device such as a smart phone, a desktop computer, a notebook computer, or a tablet computer, and is not limited herein.
In this embodiment of the present application, the device may be an Android system, an IOS system, or a Windows system, which is not limited herein.
Since the apparatus described in the second embodiment of the present invention is an apparatus used for implementing the method of the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific structure and the deformation of the apparatus, and thus the details are not described herein. All the devices adopted in the method of the first embodiment of the present invention belong to the protection scope of the present invention.
Based on the same inventive concept, the application provides a corresponding electronic device embodiment, which is detailed in
Example three.
EXAMPLE III
The present embodiment provides an electronic device, as shown in fig. 3, which includes a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor 320, and when the processor 320 executes the computer program 311, any one of the embodiments may be implemented.
Since the electronic device described in this embodiment is a device used for implementing the method in the first embodiment of the present application, based on the method described in the first embodiment of the present application, a specific implementation of the electronic device in this embodiment and various variations thereof can be understood by those skilled in the art, and therefore, how to implement the method in the first embodiment of the present application by the electronic device is not described in detail herein. The equipment used by those skilled in the art to implement the methods in the embodiments of the present application is within the scope of the present application.
Based on the same inventive concept, the application provides a storage medium corresponding to the fourth embodiment, which is described in detail in the fourth embodiment.
Example four
The embodiment provides a computer-readable storage medium 400, as shown in fig. 4, on which a computer program 411 is stored, and when the computer program 411 is executed by a processor, any one of the embodiment modes can be implemented.
The technical scheme provided in the embodiment of the application has at least the following technical effects or advantages:
in the method, the device, the equipment and the medium provided by the embodiment of the application, whether the remote procedure call is a synchronous call is judged; if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not; if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time; if the waiting time is not less than the preset overtime time, ending the remote procedure call; if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function; if the return value of the interrupt function is true, ending the remote procedure call; if the return value of the interrupt function is not true, judging whether a return result of the called end is received; if the return result of the called end is received, ending the remote procedure call; and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset time. The remote procedure call can be ended by setting the interrupt function in the synchronous call of the remote procedure before receiving the call result or calling overtime so as to enable the current thread to be in a runnable state, and the problem that the current thread can be continuously executed only by waiting for the call result or calling overtime in the prior art is solved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made in the embodiments of the present invention without departing from the spirit or scope of the embodiments of the invention. Thus, if such modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to encompass such modifications and variations.

Claims (10)

1. An interruptible remote procedure call method, comprising:
judging whether the remote procedure call is a synchronous call;
if the remote procedure call is a synchronous call, judging whether the remote procedure call is set to be interruptible or not;
if the remote procedure call is set to be interruptible, after sending a remote procedure call message to a called end, judging whether the waiting time is less than preset timeout time;
if the waiting time is not less than the preset overtime time, ending the remote procedure call;
if the waiting time is less than the preset overtime, judging whether to end the remote procedure call according to the return value of the interrupt function;
if the return value of the interrupt function is true, ending the remote procedure call;
if the return value of the interrupt function is not true, judging whether a return result of the called end is received;
if the return result of the called end is received, ending the remote procedure call;
and if the return result of the called end is not received, continuing to execute the judgment whether the waiting time is less than the preset overtime time.
2. The method of claim 1, wherein determining whether the remote procedure call is a synchronous call comprises:
judging whether the remote procedure CALL is a synchronous CALL or not according to the value of an RPC _ ATTR _ ASYNC _ CALL attribute, wherein the RPC _ ATTR _ ASYNC _ CALL attribute is used for setting a calling mode;
if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 0, determining that the remote procedure CALL is a synchronous CALL;
and if the value of the RPC _ ATTR _ ASYNC _ CALL attribute is 1, determining that the remote procedure CALL is an asynchronous CALL.
3. The method of claim 1, wherein determining whether the remote procedure call is set to interruptible comprises:
setting an interrupt CALLBACK FUNCTION with an RPC _ ATTR _ CALLBACK _ FUNCTION attribute registration type of RPC _ POLL _ TASK, wherein the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is used for setting the CALLBACK FUNCTION in the FUNCTION;
judging whether the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0 or not;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is not 0, determining that the remote procedure call is set to be interruptible;
if the value of the RPC _ ATTR _ CALLBACK _ FUNCTION attribute is 0, determining that the remote procedure call is set to be non-interrupted.
4. The method of claim 1, wherein after determining whether the remote procedure call is set to interruptible, further comprising:
serializing an IRpcArgment type remote procedure call parameter into the remote procedure call message;
creating a remote procedure call message combination structure body, wherein the remote procedure call message combination structure body comprises an rpcMessage field, a mutual exclusion lock member, a condition member and a result member, the mutual exclusion lock member is used for controlling a function not to return, the condition member is used for setting a condition for executing the function, and the result member is used for setting a result returned to a call end;
and storing the remote procedure call message into the rpcMessage field.
5. The method of claim 4, wherein if the return value of the interrupt function is true, ending the remote procedure call comprises:
if the return value of the interrupt function is true, setting a result member of the remote procedure call message combination structure body as ERROR _ INTERRUPTED to represent that the remote procedure call is INTERRUPTED;
and returning the result member as a return value to the calling end, thereby finishing the remote procedure call.
6. The method of claim 4, wherein if the wait time is not less than the preset timeout time, ending the remote procedure call comprises:
if the waiting time is not less than the preset TIMEOUT time, setting a result member of the remote procedure call message combination structure as ERROR _ TIMEOUT, and indicating that the remote procedure call is TIMEOUT;
and returning the result member as a return value to a calling end, thereby finishing the remote procedure call.
7. The method of claim 4, wherein after determining whether the remote procedure call is set to interruptible, further comprising:
if the remote procedure call is set to be non-interrupted, after the remote procedure call message is sent to the called end, executing non-interrupted synchronous call;
in the non-interrupted synchronous call, calling a timed _ wait method of the conditional member, transmitting the mutex lock member into a first parameter of the timed _ wait method, and transmitting the preset timeout time into a second parameter of the timed _ wait method, so that the timed _ wait method does not return within the preset timeout time;
if the return result of the called end is received within the preset timeout time, calling a signal _ one method of the condition member to trigger the timed _ wait method to return true, indicating that the remote procedure call is not timeout, storing the return result of the called end to the result member and then returning to the calling end, thereby ending the remote procedure call;
if the returned result of the called end is not received within the preset TIMEOUT period, the timed _ wait method returns false, which indicates that the remote procedure call is overtime, and returns to the calling end after the result member is set as ERROR _ TIMEOUT, thereby ending the remote procedure call.
8. An interruptible remote procedure call apparatus, comprising:
the first judgment unit is used for judging whether the remote procedure call is a synchronous call;
a second determining unit, configured to determine whether the remote procedure call is set to be interruptible if the remote procedure call is a synchronous call;
a third judging unit, configured to, if the remote procedure call is set to be interruptible, judge whether the waiting time is less than a preset timeout after sending the remote procedure call message to the called end;
a first ending unit, configured to end the remote procedure call if the waiting time is not less than the preset timeout time;
a fourth judging unit, configured to judge whether to end the remote procedure call according to a return value of the interrupt function if the waiting time is less than a preset timeout;
a second ending unit, configured to end the remote procedure call if a return value of the interrupt function is true;
a fifth judging unit, configured to judge whether a return result of the called end is received if the return value of the interrupt function is not true;
a third ending unit, configured to end the remote procedure call if a return result of the called end has been received;
and if the return result of the called end is not received, continuing to execute the operation of the third judging unit.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1-7 when executing the program.
10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out the method of any one of claims 1 to 7.
CN201810750589.5A 2018-07-10 2018-07-10 Interruptible remote procedure calling method and interruptible remote procedure calling device Active CN110704203B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810750589.5A CN110704203B (en) 2018-07-10 2018-07-10 Interruptible remote procedure calling method and interruptible remote procedure calling device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810750589.5A CN110704203B (en) 2018-07-10 2018-07-10 Interruptible remote procedure calling method and interruptible remote procedure calling device

Publications (2)

Publication Number Publication Date
CN110704203A CN110704203A (en) 2020-01-17
CN110704203B true CN110704203B (en) 2022-08-16

Family

ID=69192366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810750589.5A Active CN110704203B (en) 2018-07-10 2018-07-10 Interruptible remote procedure calling method and interruptible remote procedure calling device

Country Status (1)

Country Link
CN (1) CN110704203B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769824B (en) * 2021-01-07 2023-03-07 深圳市大富网络技术有限公司 Information transmission state updating method, terminal, device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1635485A (en) * 2003-12-26 2005-07-06 华为技术有限公司 Time-out adaptive method in remote synchronous calling procedure
JP2006185229A (en) * 2004-12-28 2006-07-13 Hitachi Ltd Online synchronous processing method and device
CN105049255A (en) * 2015-08-05 2015-11-11 大唐移动通信设备有限公司 Net element data synchronization method and device thereof
CN106161537A (en) * 2015-04-10 2016-11-23 阿里巴巴集团控股有限公司 The processing method of remote procedure call, device, system and electronic equipment
CN107466467A (en) * 2016-06-22 2017-12-12 深圳市大疆创新科技有限公司 The method, apparatus and system of a kind of remote synchronization

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8359588B2 (en) * 2009-11-25 2013-01-22 Arm Limited Reducing inter-task latency in a multiprocessor system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1635485A (en) * 2003-12-26 2005-07-06 华为技术有限公司 Time-out adaptive method in remote synchronous calling procedure
JP2006185229A (en) * 2004-12-28 2006-07-13 Hitachi Ltd Online synchronous processing method and device
CN106161537A (en) * 2015-04-10 2016-11-23 阿里巴巴集团控股有限公司 The processing method of remote procedure call, device, system and electronic equipment
CN105049255A (en) * 2015-08-05 2015-11-11 大唐移动通信设备有限公司 Net element data synchronization method and device thereof
CN107466467A (en) * 2016-06-22 2017-12-12 深圳市大疆创新科技有限公司 The method, apparatus and system of a kind of remote synchronization

Also Published As

Publication number Publication date
CN110704203A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
US9990209B2 (en) Digital assistance device for facilitating multi-stage setup
CN104182683A (en) Method, device and system for monitoring online transactions
CN107273226B (en) Method and device for integrating components in android system and calling integrated components
CN110704203B (en) Interruptible remote procedure calling method and interruptible remote procedure calling device
EP3188071B1 (en) Application accessing control method and device
CN113190427A (en) Caton monitoring method and device, electronic equipment and storage medium
CN110688203B (en) Task execution method and device
CN109426529B (en) Method, device and terminal for drawing graphics based on X window system
CN113010285B (en) Method, apparatus, device, medium, and article for processing data
CN113112217B (en) Business process configuration method, device, electronic equipment and computer readable medium
CN106708737B (en) Test method and device
CN115344370A (en) Task scheduling method, device, equipment and storage medium
CN112379952B (en) Method for implementing cross-process callback
CN115242972A (en) Method and device for calling camera by application, electronic equipment and storage medium
CN114625458A (en) Page data processing method and device, electronic equipment and storage medium
CN109815429B (en) Browser page closing processing method and device
CN113419865A (en) Cloud resource processing method, related device and computer program product
CN110825461B (en) Data processing method and device
CN109150993B (en) Method for obtaining network request tangent plane, terminal device and storage medium
CN111737036A (en) Service processing method and device based on robot process automation
CN112860419A (en) Multi-instance task execution method and device, terminal equipment and computer storage medium
CN105260233A (en) Application container creating method and apparatus
CN108776623B (en) Optimization method, computer equipment and storage medium
CN111737372A (en) Map data generation method and device
CN110070176A (en) The processing method of off-line model, the processing unit of off-line model and Related product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240322

Address after: Room 601, 6th Floor, Building 5, Lianhuayuan, Haidian District, Beijing, 100080

Patentee after: Aerospace Guosheng Technology Co.,Ltd.

Country or region after: China

Address before: 430000 East Lake Development Zone, Wuhan City, Hubei Province, No. 1 Software Park East Road 4.1 Phase B1 Building 11 Building

Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right