Asynchronous method invocation: Difference between revisions

Content deleted Content added
Background: removed internal link from a different ___domain but related name, stated name in quotes
Background: typing correction
Line 3:
== Background ==
'''AMI''' is a [[software design pattern|design pattern]] for [[asynchrony (computer programming)|asynchronous]] invocation of potentially long-running [[method (computer science)|methods]] of an [[object (computer science)|object]].<ref name="Async.34.2#71139">{{cite web|url=http://www.zeroc.com/doc/Ice-3.2.1/manual/Async.34.2.html#71139 |title=Asynchronous Method Invocation |accessdate=22 November 2008 |website=Distributed Programming with Ice |publisher=ZeroC, Inc. |deadurl=yes |archiveurl=https://web.archive.org/web/20080105093534/http://www.zeroc.com/doc/Ice-3.2.1/manual/Async.34.2.html |archivedate=5 January 2008 |df= }}</ref>
It is equivalent to the IOU ("OI ove you") pattern described in 1996 by Allan Vermeulen.<ref>{{cite journal |last=Vermeulen |first=Allan |date=June 1996 |title=An Asynchronous Design Pattern |journal=[[Dr. Dobb's Journal]] |url=http://www.ddj.com/184409898 |accessdate=22 November 2008 }}</ref><ref>{{cite book |last=Nash |first=Trey |title=Accelerated C# 2008 | year=2007 |publisher=Apress |isbn=978-1-59059-873-3 |chapter=Threading in C# }}</ref>
 
In most programming languages a called method is executed synchronously, i.e. in the [[thread (computer science)|thread of execution]] from which it is invoked. If the method takes a long time to complete, e.g. because it is loading data over the internet, the calling thread is blocked until the method has finished. When this is not desired, it is possible to start a "worker thread" and invoke the method from there. In most programming environments this requires many lines of code, especially if care is taken to avoid the overhead that may be caused by creating many threads. AMI solves this problem in that it augments a potentially long-running ("synchronous") object method with an "asynchronous" variant that returns immediately, along with additional methods that make it easy to receive notification of completion, or to wait for completion at a later time.