# Patent

## Title
Technologies for detecting erroneous resumptions in a continuation based runtime

## Abstract

Technologies for enabling a continuation based runtime to accept or reject external stimulus and, in addition, to determine if an external stimulus may be valid for processing at a later point in execution.

## Background
BACKGROUND
A continuation based runtime typically executes activities or programs. An activity typically represents a unit of executable code consisting of multiple pulses of work. One manner in which an activity can execute multiple pulses of work is through the scheduling of child activities. Such a composition of activities typically enables custom control flows that can be implemented through the scheduling of child activities zero or more times as determined by the composite activity. An activity can also setup a resumable continuation or bookmark in its execution that is resumed by a stimulus external to the runtime. The runtime interprets this external stimulus as another pulse of work to be handled by the activity. Pulses of work are typically represented as continuations that the runtime invokes on activities (thus, continuation based runtime). Beyond the flexibility to create new control flows and handle external resumptions, activities generally include the following characteristics: they have no process affinity—they can be paused and resumed in a different process; they have no thread affinity—different pulses of work can run on different threads; they can be persisted and rehydrated.
Dealing with external stimuli can present several complications. For example, multiple stimuli can occur simultaneously. In general, a continuation based runtime processes stimuli as they arrive. A continuation based runtime should be capable of predictably managing multiple external stimuli relative to internal state. Such management is typically performed by assessing validity of the stimulus either for immediate processing or by determining that the activity will never enter a state wherein the stimulus is valid. Such management typically results in a program's ability to accept or reject a stimulus. But it may be desirable to further determine if the stimulus may be valid for processing at a later point in the activity.
SUMMARY
The following presents a simplified summary of the disclosure in order to provide a basic understanding to the reader. This summary is not an extensive overview of the disclosure and it does not identify key/critical elements of the invention or delineate the scope of the invention. Its sole purpose is to present some concepts disclosed herein in a simplified form as a prelude to the more detailed description that is presented later.
The present examples provide technologies for enabling a continuation based runtime to accept or reject external stimulus and, in addition, to determine if an external stimulus may be valid for processing at a later point in execution.
Many of the attendant features will be more readily appreciated as the same become better understood by reference to the following detailed description considered in connection with the accompanying drawings.



DESCRIPTION OF THE DRAWINGS
The present description will be better understood from the following detailed description considered in connection with the accompanying drawings, wherein:
FIG. 1 is a block diagram showing an example continuation based runtime system and an example activity along with example interactions with an example database and an example service.
FIG. 2 is a block diagram showing an example method for determining if a request to resume a CContinuation can be immediately accepted, or accepted at a later point in execution, or if it can be immediately rejected.
FIG. 3 is a block diagram showing an example method for determining stability of a conversation.
FIG. 4 is a block diagram showing an example computing environment in which the technologies described herein may be implemented.



Like reference numerals are used to designate like parts in the accompanying drawings.
DETAILED DESCRIPTION
The detailed description provided below in connection with the accompanying drawings is intended as a description of the present examples and is not intended to represent the only forms in which the present examples may be constructed or utilized. The description sets forth at least some of the functions of the examples and/or the sequence of steps for constructing and operating examples. However, the same or equivalent functions and sequences may be accomplished by different examples.
Although the present examples are described and illustrated herein as being implemented in a computing and networking environment, the environment described is provided as an example and not a limitation. As those skilled in the art will appreciate, the present examples are suitable for application in a variety of different types of computing and networking environments.
FIG. 1 is a block diagram showing an example continuation based runtime (“CBR”) system 110 and an example activity 120 along with example interactions (1) through (11) with an example database (“DB”) 130 and an example service 140. CBR 110 is shown to include an example continuation list 114 and example stability calculator 112 among other elements not shown. Continuation list 114 typically includes a list of continuations that have been created by activities executing in CBR 110.
In one example, CBR 110 supports at least two different types of continuations: conversation continuations and non-conversation continuations. A conversation continuation (“CContinuation”) is generally a continuation associated with a conversation between an activity, such as activity 120, and some external party or service, such as service 140. Such a conversation may make use of any suitable protocol and may take place over any span of time, short or long, even over a period of years. In general, an activity (or child activity) may send a message to another party, the message eliciting a responsive message in return. The responsive message may take some time, short or long, even up to several years, to arrive. After sending the initial message, the activity typically creates a CContinuation and then ceases execution while waiting for the response, thus allowing other activities or child activities to be executed or further executed by the CBR. A responsive message typically comprises a request to resume the CContinuation. If the responsive message and/or request to resume are valid, then CBR 110 typically provides the responsive message to activity 120 and executes the CContinuation, thus continuing execution of the activity with the responsive message it was waiting for starting at the point that it ceased execution.
A non-conversation continuation (“NCContinuation”) is generally a continuation controlled by an activity or child activity itself when performing some form of external asynchronous (blocking) operation. Requests to resume a NCContinuation generally come from the same activity or child activity that created the NCContinuation as opposed to another party. For example, an activity may request that some information be written to a database, an operation that may take some time, short or long. Once such an operation is complete or the like, a status message of any suitable form is typically returned. Upon receipt of such a status message, activity 120 typically makes a request to resume the NCContinuation corresponding to the status message and CBR 110 continues execution of the activity with the status message it was waiting for starting at the point that it ceased execution.
Continuation list 114 typically contains a list of active continuations such as CContinuations and NCContinuations after they have been created and at least until that have been executed or canceled or the like. Such a list may include additional information about each continuation such as its type (conversation, non-conversation, etc), an identifier (“ID”) for the activity or child activity it is associated with, an ID for the conversation it is associated with, a list of governing continuations, etc. In one example, a governing continuation is a continuation on which another continuation is dependent before it can continue execution—that is, a governing continuation must be executed before the continuation is depends on can execute.
Stability calculator 112 typically determines if a request to resume a CContinuation can be immediately accepted, or accepted at a later point in execution, or if it can be immediately rejected. The method for making this determination is described herein below in connection with FIGS. 2 and 3.
Example activity 120 shows a sequence of three child activities. First, WriteDB 122 provides some information to be written into DB 130. Second, Receive Message A 124 expects to receive a Message A as part of a conversation from Service A. Third, Receive Message B expects to receive a Message B as part of a conversation from some other external party. Not shown, both Message A and Message B are part of the same conversation (i.e., are associated with the same conversation ID). In one example, a default conversation ID is associated with all conversations unless otherwise specified.
Activity 120 is a simplified example that may be executed in CBR 110, which may operate in a computing environment such as that described in connection with FIG. 4 or the like. An activity is generally analogous to a program and is typically comprised of computer-executable instructions or the like. An activity may be subdivided into a sequence of child activities (also comprised of computer-executable instructions or the like) such as examples 122, 124, and 126. CBR 110 may execute a plurality of activities concurrently; a single activity 120 and steps (1) through (11) are shown simply as a matter of convenience and for clarity of discussion herein and not as a limitation. Many other child activities, steps, and/or sequences of activities, child activities, and/or steps may alternatively or additionally be executed in a CBR system or the like.
Step (1) shows WriteDB 122 starting an asynchronous operation to write some information to DB 130. Step (2) shows WriteDB 122 creating an NCContinuation for the asynchronous operation and waiting until a status message is returned from DB 130 indicating the completion status of the requested asynchronous operation. Step (3) shows a request to resume CContinuation for Message A (for conversation ID=n) from Service A 140. Note that no CContinuation for Message A has been created to resume at this point in the execution. Step (4) shows stability calculator 112 checking conversation n for stability as described herein below. Since conversation n is unstable, the request to resume the CContinuation for Message A may be accepted at a later point in execution. Step (5) shows DB 130 returning the status message regarding the asynchronous operation. Step (6) shows WriteDB 122 requesting to resume the NCContinuation associated with the asynchronous operation. Step (7) shows CBR 110 continuing execution of WriteDB 122 responsive to the request to resume. Step (8) shows Receive Message A creating a CContinuation for Message A (conversation ID=n); activity 120 then ceases execution. Step (9) shows stability calculator 112 again checking conversation n for stability as described herein below. Since conversation n is now stable, the request to resume CContinuation for Message A from step (3) may be immediately accepted. Step (10) shows execution of Receive Message A 124 being resumed. Step (11) shows a return of “successful” responsive to the request to resume of step (3).
FIG. 2 is a block diagram showing an example method 200 for determining if a request 202 to resume a CContinuation (e.g., CContinuation ID=i) can be immediately accepted, or accepted at a later point in execution, or if it can be immediately rejected. Method 200 includes block 230 which indicates a method (one example is described in connection with FIG. 3) for determining if a conversation associated with the CContinuation is stable or not. Method 200 is generally performed in response to a request 202 to resume a CContinuation that is associated with a particular conversation (e.g., conversation ID=n). Method 200 is generally performed by a CBR such as CBR 110 of FIG. 1. Method 200 is typically performed in the context of an activity (e.g., activity ID=b) when the activity is idle (i.e., when the activity and its child activities are not executing).
Block 210 typically indicates checking to see if the CContinuation exists. In one example, this includes checking a continuation list, such as list 114 of FIG. 1, to see if CContinuation ID=i has been created. If the CContinuation does exist, then method 200 typically continues at block 220. Otherwise, method 200 typically continues at block 230.
Block 220 typically indicates accepting request 202 and immediately resuming the CContinuation responsive to request 202. In one example, this includes continuing or resuming execution of the activity or child activity that created the CContinuation. This may also including providing information to the activity or child activity from the external party requesting the resumption of the CContinuation, examples of information including, but not limited to, a message or status message or the like including any data suitable to the conversation. Once the CContinuation has been resumed, method 200 is typically complete.
Block 230 typically indicates determining if the conversation associated with the CContinuation is stable. An example method for checking stability is described in connection with FIG. 3. If the conversation is stable, then method 200 typically continues at block 240. Otherwise, method 200 typically continues at block 250.
Block 240 typically indicates rejecting request 202 to resume the CContinuation. This typically includes returning a “failed” message or the like to the party submitting request 202. In this case, there is no CContinuation currently in existence corresponding to request 202 and the conversation associated with request 202 is considered stable (or the conversation associated with request 202 is currently unknown by the means of performing method 200). Note that a CContinuation matches a request if the CContinuation ID of the CContinuation and request match and the associated conversation ID of the CContinuation and request match. Accordingly, in this case no corresponding CContinuation currently exists to resume so a failure message is returned. Once the failure message is returned, method 200 is typically complete.
Block 250 typically indicates determining if a timeout period has expired. This typically includes determining if a particular amount of time has transpired since request 202 has arrived and has not been either accepted or failed. The particular amount of time may be short or long. If there is still time remaining to accept or reject request 202 then method 200 typically continues at block 270. Otherwise, method 200 typically continues at block 260.
Block 260 typically indicates request 202 being timed-out. This typically includes rejecting request 202 and retuning a “timeout” message or the like to the party submitting request 202. In this case there is no CContinuation currently in existence corresponding to request 202 and the conversation associated with request 202 is not considered stable. Once the timeout message is returned, method 200 is typically complete.
Block 270 typically indicates delaying a determination to accept or reject request 202 until a future point in the execution of the corresponding activity or child activity. The delay may end after a specified period of time, short or long, or may end after the creation of a matching CContinuation. Once the delay end, method 200 typically continues at block 210.
FIG. 3 is a block diagram showing an example method 300 for determining stability of a conversation. Method 300 is generally performed in response to a request 302 to determine if a conversation (e.g., conversation ID=n) is stable, typically a conversation associated with a CContinuation of interest. Method 300 is generally performed by a CBR such as CBR 110 of FIG. 1. Method 300 is typically performed in the context of an activity (e.g., activity ID=b) when the activity is idle (i.e., when the activity and its child activities are not executing).
Block 310 typically indicates determining if any NCContinuations currently exist in the context of the activity (e.g., activity ID=b). If any such NCContinuations do exist, then the conversation is considered unstable. If the conversation is considered unstable, then method 300 typically returns an unstable indicator 330. Otherwise, method 330 typically continues at block 320.
Block 320 typically indicates determining if any governing continuations exist that are associated with the CContinuation of interest. If any such governing continuations do exist, then the conversation is considered unstable. If the conversation is considered unstable, then method 300 typically returns an unstable indicator 330. Otherwise, method 330 typically returns a stable indicator 340.
FIG. 4 is a block diagram showing an example computing environment 400 in which the technologies described herein may be implemented. A suitable computing environment may be implemented with numerous general purpose or special purpose systems. Examples of well known systems may include, but are not limited to, cell phones, personal digital assistants (“PDA”), personal computers (“PC”), hand-held or laptop devices, microprocessor-based systems, multiprocessor systems, servers, workstations, consumer electronic devices, set-top boxes, and the like.
Computing environment 400 typically includes a general-purpose computing system in the form of a computing device 401 coupled to various components, such as peripheral devices 402, 403, 404 and the like. System 400 may couple to various other components, such as input devices 403, including voice recognition, touch pads, buttons, keyboards and/or pointing devices, such as a mouse or trackball, via one or more input/output (“I/O”) interfaces 412. The components of computing device 401 may include one or more processors (including central processing units (“CPU”), graphics processing units (“GPU”), microprocessors (“μP”), and the like) 407, system memory 409, and a system bus 408 that typically couples the various components. Processor 407 typically processes or executes various computer-executable instructions to control the operation of computing device 401 and to communicate with other electronic and/or computing devices, systems or environment (not shown) via various communications connections such as a network connection 414 or the like. System bus 408 represents any number of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a serial bus, an accelerated graphics port, a processor or local bus using any of a variety of bus architectures, and the like.
System memory 409 may include computer readable media in the form of volatile memory, such as random access memory (“RAM”), and/or non-volatile memory, such as read only memory (“ROM”) or flash memory (“FLASH”). A basic input/output system (“BIOS”) may be stored in non-volatile or the like. System memory 409 typically stores data, computer-executable instructions and/or program modules comprising computer-executable instructions that are immediately accessible to and/or presently operated on by one or more of the processors 407.
Mass storage devices 404 and 410 may be coupled to computing device 401 or incorporated into computing device 401 via coupling to the system bus. Such mass storage devices 404 and 410 may include non-volatile RAM, a magnetic disk drive which reads from and/or writes to a removable, non-volatile magnetic disk (e.g., a “floppy disk”) 405, and/or an optical disk drive that reads from and/or writes to a non-volatile optical disk such as a CD ROM, DVD ROM 406. Alternatively, a mass storage device, such as hard disk 410, may include non-removable storage medium. Other mass storage devices may include memory cards, memory sticks, tape storage devices, and the like.
Any number of computer programs, files, data structures, and the like may be stored in mass storage 410, other storage devices 404, 405, 406 and system memory 409 (typically limited by available space) including, by way of example and not limitation, operating systems, application programs, data files, directory structures, computer-executable instructions, and the like.
Output components or devices, such as display device 402, may be coupled to computing device 401, typically via an interface such as a display adapter 411. Output device 402 may be a liquid crystal display (“LCD”). Other example output devices may include printers, audio outputs, voice outputs, cathode ray tube (“CRT”) displays, tactile devices or other sensory output mechanisms, or the like. Output devices may enable computing device 401 to interact with human operators or other machines, systems, computing environments, or the like. A user may interface with computing environment 400 via any number of different I/O devices 403 such as a touch pad, buttons, keyboard, mouse, joystick, game pad, data port, and the like. These and other I/O devices may be coupled to processor 407 via I/O interfaces 412 which may be coupled to system bus 408, and/or may be coupled by other interfaces and bus structures, such as a parallel port, game port, universal serial bus (“USB”), fire wire, infrared (“IR”) port, and the like.
Computing device 401 may operate in a networked environment via communications connections to one or more remote computing devices through one or more cellular networks, wireless networks, local area networks (“LAN”), wide area networks (“WAN”), storage area networks (“SAN”), the Internet, radio links, optical links and the like. Computing device 401 may be coupled to a network via network adapter 413 or the like, or, alternatively, via a modem, digital subscriber line (“DSL”) link, integrated services digital network (“ISDN”) link, Internet link, wireless link, or the like.
Communications connection 414, such as a network connection, typically provides a coupling to communications media, such as a network. Communications media typically provide computer-readable and computer-executable instructions, data structures, files, program modules and other data using a modulated data signal, such as a carrier wave or other transport mechanism. The term “modulated data signal” typically means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communications media may include wired media, such as a wired network or direct-wired connection or the like, and wireless media, such as acoustic, radio frequency, infrared, or other wireless communications mechanisms.
Power source 490, such as a battery or a power supply, typically provides power for portions or all of computing environment 400. In the case of the computing environment 400 being a mobile device or portable device or the like, power source 490 may be a battery. Alternatively, in the case computing environment 400 is a desktop computer or server or the like, power source 490 may be a power supply designed to connect to an alternating current (“AC”) source, such as via a wall outlet.
Some mobile devices may not include many of the components described in connection with FIG. 4. For example, an electronic badge may be comprised of a coil of wire along with a simple processing unit 407 or the like, the coil configured to act as power source 490 when in proximity to a card reader device or the like. Such a coil may also be configure to act as an antenna coupled to the processing unit 407 or the like, the coil antenna capable of providing a form of communication between the electronic badge and the card reader device. Such communication may not involve networking, but may alternatively be general or special purpose communications via telemetry, point-to-point, RF, IR, audio, or other means. An electronic card may not include display 402, I/O device 403, or many of the other components described in connection with FIG. 4. Other mobile devices that may not include many of the components described in connection with FIG. 4, by way of example and not limitation, include electronic bracelets, electronic tags, implantable devices, and the like.
Those skilled in the art will realize that storage devices utilized to provide computer-readable and computer-executable instructions and data can be distributed over a network. For example, a remote computer or storage device may store computer-readable and computer-executable instructions in the form of software applications and data. A local computer may access the remote computer or storage device via the network and download part or all of a software application or data and may execute any computer-executable instructions. Alternatively, the local computer may download pieces of the software or data as needed, or distributively process the software by executing some of the instructions at the local computer and some at remote computers and/or devices.
Those skilled in the art will also realize that, by utilizing conventional techniques, all or portions of the software's computer-executable instructions may be carried out by a dedicated electronic circuit such as a digital signal processor (“DSP”), programmable logic array (“PLA”), discrete circuits, and the like. The term “electronic apparatus” may include computing devices or consumer electronic devices comprising any software, firmware or the like, or electronic devices or circuits comprising no software, firmware or the like.
The term “firmware” typically refers to executable instructions, code, data, applications, programs, or the like maintained in an electronic device such as a ROM. The term “software” generally refers to executable instructions, code, data, applications, programs, or the like maintained in or on any form of computer-readable media. The term “computer-readable media” typically refers to system memory, storage devices and their associated media, and the like.
In view of the many possible embodiments to which the principles of the present invention and the forgoing examples may be applied, it should be recognized that the examples described herein are meant to be illustrative only and should not be taken as limiting the scope of the present invention. Therefore, the invention as described herein contemplates all such embodiments as may come within the scope of the following claims and any equivalents thereto.

## Claims

1. A method of handling a request to resume a conversation continuation, the method comprising:
receiving, by a processor, the request from an external service to resume the conversation continuation;
determining, by the processor, if a conversation is stable, the conversation being associated with the conversation continuation referred to by the request, wherein the request to resume the conversation continuation is associated with an activity that has no process affinity, no thread affinity, and can be persistent;
accepting the request and resuming the conversation, by the processor, in response to determining that the conversation continuation exists;
otherwise, rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is stable; and
otherwise, delaying the handling of the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that a particular amount of time has not transpired between the receiving the request and the accepting or the rejecting the request.

2. The method of claim 1 further comprising rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that the particular amount of time has transpired.

3. The method of claim 1 further comprising delaying the handling of the request until a conversation continuation is created by the activity that is referred to by the request.

4. The method of claim 1 further comprising delaying the handling of the request until the conversation becomes stable.

5. The method of claim 1 wherein accepting the request comprises continuing execution of the activity.

6. The method of claim 1 wherein rejecting the request comprises returning a failure message to the external service making the request.

7. The method of claim 1 wherein the determining that the conversation is unstable comprises determining that a non-conversation continuation exists that is associated with the activity.

8. The method of claim 1 wherein the determining that the conversation is unstable comprises determining that a governing continuation exists that is associated with the activity.

9. At least one storage device storing computer executable instructions that, when executed by a processor, cause the processor to perform a method of handling a request to resume a conversation continuation, the method comprising:
receiving the request from an external service to resume the conversation continuation;
determining if a conversation is stable, the conversation being associated with the conversation continuation referred to by the request, wherein the request to resume the conversation continuation is associated with an activity that has no process affinity, no thread affinity, and can be persistent;
accepting the request and resuming the conversation in response to determining that the conversation continuation exists;
otherwise, rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is stable; and
otherwise, delaying the handling of the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that a particular amount of time has not transpired between the receiving the request and the accepting or the rejecting the request.

10. The at least one storage device of claim 9, the method further comprising rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that the particular amount of time has transpired.

11. The at least one storage device of claim 9, the method further comprising delaying the handling of the request until a conversation continuation is created by the activity that is referred to by the request.

12. The at least one storage device of claim 9, the method further comprising delaying the handling of the request until the conversation becomes stable.

13. The at least one storage device of claim 9 wherein the determining that the conversation is unstable comprises determining that a non-conversation continuation exists that is associated with the activity.

14. The at least one storage device of claim 9 wherein the determining that the conversation is unstable comprises determining that a governing continuation exists that is associated with the activity.

15. A system for handling a request to resume a conversation continuation, the system comprising:
a processor;
the processor configured for receiving a request to resume a conversation from an external service;
the processor further configured for determining if a conversation is stable, the conversation being associated with the conversation continuation referred to by the request, wherein the request to resume the conversation continuation is associated with an activity that has no process affinity, no thread affinity, and can be persistent;
the processor further configured for accepting the request and resuming the conversation in response to determining that the conversation continuation exists;
the processor further configured for otherwise rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is stable; and
the processor further configured for otherwise delaying the handling of the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that a particular amount of time has not transpired between arrival of the request and accepting or rejecting the request.

16. The at least one storage device of claim 15, the method further comprising rejecting the request in response to determining that the conversation continuation does not exist and that the conversation associated with the conversation continuation is unstable and that the particular amount of time has transpired.

17. The at least one storage device of claim 15, the method further comprising delaying the handling of the request until a conversation continuation is created by the activity that is referred to by the request.

18. The at least one storage device of claim 15, the method further comprising delaying the handling of the request until the conversation becomes stable.

19. The at least one storage device of claim 15 wherein the determining that the conversation is unstable comprises determining that a non-conversation continuation exists that is associated with the activity.

20. The at least one storage device of claim 15 wherein the determining that the conversation is unstable comprises determining that a governing continuation exists that is associated with the activity.