# Asynchrony (computer programming)

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Asynchrony_(computer_programming)
> Markdown URL: https://mediated.wiki/source/Asynchrony_(computer_programming).md
> Source: https://en.wikipedia.org/wiki/Asynchrony_(computer_programming)
> Source revision: 1325407827
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Computer programming technique}}
<!-- DO NOT ADD DISAMBIGUATION TAGS TO THIS PAGE (per [WP:INCOMPDAB](/source/WP%3AINCOMPDAB) and [WP:DABCONCEPT](/source/WP%3ADABCONCEPT)) -->
'''Asynchrony''', in [computer programming](/source/computer_programming), refers to the occurrence of events independent of the main [program flow](/source/control_flow) and ways to deal with such events. These may be "outside" events such as the arrival of [signals](/source/Unix_signal), or actions instigated by a program that take place [concurrently](/source/concurrent_computing) with program execution, without the program [hanging](/source/hang_(computing)) to wait for results.<ref name="davies">{{cite book |title=Async in C# 5.0 |first=Alex |last=Davies |publisher=O'Reilly |year=2012 |pages=1–2 |isbn=9781449337124 |url=https://books.google.com/books?id=xT45qhFrVnUC}}</ref> [Asynchronous input/output](/source/Asynchronous_I%2FO) is an example of the latter case of asynchrony, and lets programs issue commands to storage or network devices that service these requests while the [processor](/source/Central_processing_unit) continues executing the program. Doing so provides a degree of [concurrency](/source/Concurrency_(computer_science)).{{r|davies}}

A common way for dealing with asynchrony in a [programming interface](/source/application_programming_interface) is to provide [subroutine](/source/subroutine)s that return a [future or promise](/source/futures_and_promises) that represents the ongoing operation, and a synchronizing operation that [blocks](/source/Blocking_(computing)) until the future or promise is completed. Some programming languages, such as [Cilk](/source/Cilk), have special syntax for expressing an asynchronous procedure call.<ref name="spp">{{cite book |first1=Michael |last1=McCool |first2=James |last2=Reinders |first3=Arch |last3=Robison |title=Structured Parallel Programming: Patterns for Efficient Computation |publisher=Elsevier |year=2013 |pages=30}}</ref>

Examples of asynchrony include the following:
* [Asynchronous procedure call](/source/Asynchronous_procedure_call), a method to run a procedure concurrently, a lightweight alternative to [threads](/source/Thread_(computing)).
* [Ajax](/source/Ajax_(programming)) is a set of [client-side](/source/client-side) [web technologies](/source/web_development) used by the client to create asynchronous I/O [web application](/source/web_application)s.
* '''Asynchronous method dispatch''' (AMD), a [data communication](/source/data_communication) method used when there is a need for the server side to handle a large number of long lasting client requests.<ref>[https://web.archive.org/web/20130721031512/http://zeroc.com/doc/Ice-3.3.0/manual/Overview.3.2.html ICE usage of AMD].</ref> Using synchronous method dispatch (SMD), this scenario may turn the server into an unavailable busy state resulting in a connection failure response caused by a [network](/source/Computer_network) connection request [timeout](/source/Timeout_(computing)). The servicing of a client request is immediately dispatched to an available thread from a [pool of threads](/source/Thread_pool_pattern) and the client is put in a blocking state. Upon the completion of the task, the server is notified by a callback. The server unblocks the client and transmits the response back to the client. In case of thread [starvation](/source/Starvation_(computer_science)), clients are blocked waiting for threads to become available.

==See also==
{{Portal|Computer programming}}
* [Asynchronous system](/source/Asynchronous_system)
* [Asynchronous circuit](/source/Asynchronous_circuit)

==References==
{{reflist}}
Category:Computer programming
Category:Inter-process communication
Category:Middleware

{{comp-sci-stub}}
<!-- DO NOT ADD DISAMBIGUATION TAGS TO THIS PAGE (per [WP:INCOMPDAB](/source/WP%3AINCOMPDAB) and [WP:DABCONCEPT](/source/WP%3ADABCONCEPT)) -->

---
Adapted from the Wikipedia article [Asynchrony (computer programming)](https://en.wikipedia.org/wiki/Asynchrony_(computer_programming)) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Asynchrony_(computer_programming)?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
