A computer program product for use at a computer system, the computer program product for implementing a method for representing an asynchronous method call, the computer program product comprising one or more computer storage media having stored thereon computer-executable instructions that, when executed at a processor, cause the computer system including an accessor module, a recognizer module, an identifier module, and a rewriter module to perform the method, comprising the following:
- access a portion of source code;
- recognize an asynchronous method within the portion of source code;
- identify a builder object corresponding to the asynchronous method based on one or more of the return type of the asynchronous method and other contextual information of the asynchronous method call, the builder object including instructions to expose one or more future states of the asynchronous method through a handle;
- identify a producer method configured to instantiate an instance of the builder object;
- and
- receive the identity of the asynchronous method, the builder object, and the producer method from the identifier module and rewrite the asynchronous method to:
- use the producer method to instantiate an instance of the builder object,
- generate a handle from the builder object to represent one or more future states of the asynchronous method,
- return the handle, and
- pass information about operation of the asynchronous method through the handle such that the state of the asynchronous method is trackable prior to and after completing.