Patent attributes
A system and method for implementing an asynchronous construct in a computer program. A state machine is generated from the computer program, and the program is translated to generate code that executes the state machine during runtime. The asynchronous construct may be made into a function that invokes an asynchronous function, passing the function as a callback, and then exits. When the asynchronous operation completes, the function is invoked as a callback, returning to a configuration equivalent to that prior to the asynchronous call. Variable closure may be used to maintain the state of variables during a state prior to invoking the asynchronous operation and a state after invoking the asynchronous operation.