Asynchronous method invocation: Difference between revisions

Content deleted Content added
GreenC bot (talk | contribs)
Rescuing 2 sources and tagging 1 as dead. #IABot (v1.2.5)
Line 2:
 
== 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 |work=Distributed Programming with Ice |publisher=ZeroC, Inc. |deadurl=yes |archiveurl=https://web.archive.org/web/20080105093534/http://www.zeroc.com:80/doc/Ice-3.2.1/manual/Async.34.2.html |archivedate=5 January 2008 |df= }}</ref>
It is equivalent to the [[IOU]] 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>
 
Line 13:
 
=== Java class ===
FutureTask class<ref>{{cite web|title = Class FutureTask | url = https://docs.oracle.com/javase/6/docs/api/java/util/concurrent/FutureTask.html(v=vs.110).aspx |publisher=Oracle |date=2011 |access-date=2015-06-29 }}{{dead link|date=October 2016 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> in [[Java (programming language)|Java]] use [[event (synchronization primitive)|events]] to solve the same problem. This pattern is a variant of AMI whose implementation carries more overhead, but it is useful for objects representing [[Component-based software engineering|software components]].
 
=== .NET Framework ===
Line 43:
}</source>
 
One can also pass a callback method to <code>BeginAccomplish</code>, to be invoked when the long-running method completes. It typically calls <code>EndAccomplish</code> to obtain the return value of the long-running method. A problem with the callback mechanism is that the callback function is naturally executed in the worker thread (rather than in the original calling thread), which may cause race conditions.<ref name="ms228972">{{cite web |url=http://msdn.microsoft.com/en-us/library/ms228972.aspx |title=Using an AsyncCallback Delegate to End an Asynchronous Operation |accessdate= 22 November 2008 |work=.NET Framework Developer's Guide |publisher=Microsoft Developer Network| archiveurl= https://web.archive.org/web/20081223205326/http://msdn.microsoft.com/en-us/library/ms228972.aspx| archivedate= 23 December 2008 <!--DASHBot-->| deadurl= no}}</ref><ref name="Async.34.3#76161">{{cite web |url=http://www.zeroc.com/doc/Ice-3.2.1/manual/Async.34.3.html#76161 |title=Concurrency Issues |accessdate= 22 November 2008 |work=Distributed Programming with Ice |publisher=ZeroC, Inc. |deadurl=yes |archiveurl=https://web.archive.org/web/20080328070322/http://www.zeroc.com:80/doc/Ice-3.2.1/manual/Async.34.3.html |archivedate=28 March 2008 |df= }}</ref>
 
In the .NET Framework documentation, the term event-based asynchronous pattern refers to an alternative API style (available since .NET 2.0) using a method named <code>AccomplishAsync</code> instead of <code>BeginAccomplish</code>.<ref name=nageletal>{{cite book|title=Professional C# 2008|author1=Christian Nagel |author2=Bill Evjen |author3=Jay Glynn |author4=Karli Watson |author5=Morgan Skinner |last-author-amp=yes |pages=570&ndash;571|publisher=Wiley|year=2008|isbn13=9780470191378|chapter=Event-based Asynchronous Pattern}}</ref><ref name="hkasytyf">{{cite web |url=http://msdn.microsoft.com/en-us/library/hkasytyf.aspx |title=Multithreaded Programming with the Event-based Asynchronous Pattern |accessdate= 22 November 2008 |work=.NET Framework Developer's Guide |publisher=Microsoft Developer Network| archiveurl= https://web.archive.org/web/20081225175311/http://msdn.microsoft.com/en-us/library/hkasytyf.aspx| archivedate= 25 December 2008 <!--DASHBot-->| deadurl= no}}</ref>