asynchronous programming in node - mathunipdtullio/is-1/2016/seminari/async.pdf · what is node.js?...
TRANSCRIPT
![Page 1: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/1.jpg)
Asynchronous programming in Node.js
1
![Page 2: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/2.jpg)
Asynchronous programming in Node.js
2
![Page 3: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/3.jpg)
Asynchronous programming
3
![Page 4: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/4.jpg)
Asynchronous programming
4
![Page 5: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/5.jpg)
Asynchronous programming
5
![Page 6: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/6.jpg)
Asynchronous
6
English Definition of
Adjective1. Not occurring at the same time.2. Controlling the timing of operations by the use of pulses sent
when the previous operation is completed rather than at regular intervals.
Source:https://en.oxforddictionaries.com/definition/asynchronous
![Page 7: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/7.jpg)
Asynchronous
7
English Definition of
Adjective1. Not occurring at the same time.2. Controlling the timing of operations by the use of events sent
when the previous operation is completed rather than at regular intervals.
Source: A. Maccagnan
![Page 8: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/8.jpg)
8
One step back
![Page 9: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/9.jpg)
9
What is Node.js?
![Page 10: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/10.jpg)
10
Source: Giacomo Fornari, Flipped classroom. Sistemi Concorrenti e Distribuiti 2016/2017,
http://www.slideshare.net/GiacomoFornari/nodejs-concurrency-68682939.
What is Node.js?
![Page 11: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/11.jpg)
What is Node.js?
● Event-driven● I/O● Server-side● Javascript environment● Based on V8
11
![Page 12: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/12.jpg)
What is Node.js?
5. Event-driven4. I/O3. Server side1. Javascript environment2. Based on V8
12
![Page 13: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/13.jpg)
What is Node.js?
5. Event-driven4. I/O3. Server side1. Javascript environment2. Based on V8
13
![Page 14: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/14.jpg)
What is Node.js?
2. Based on V8
14
Source: https://www.diva-portal.org/smash/get/diva2:550993/FULLTEXT01.pdf
![Page 15: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/15.jpg)
What is Node.js?
5. Event-driven4. I/O3. Server side1. Javascript environment2. Based on V8
15
![Page 16: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/16.jpg)
What is Node.js?
5. Event-driven4. I/O3. Server side1. Javascript environment2. Based on V8
16
![Page 17: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/17.jpg)
What is Node.js?
4. I/O
Source: Understanding the node.js event loop, http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop
17
![Page 18: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/18.jpg)
What is Node.js?
5. Event-driven4. I/O3. Server side1. Javascript environment2. Based on V8
18
![Page 19: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/19.jpg)
What is Node.js?
5. Event-drivenMuch of the Node.js core API is built around an idiomatic asynchronous
event-driven architecture in which certain kinds of objects (called
"emitters") periodically emit named events that cause Function objects
("listeners") to be called.
Source:
https://nodejs.org/api/events.html#events_passing_arguments_and_this
_to_listeners
19
![Page 20: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/20.jpg)
What is Node.js?
5. Event-drivenMuch of the Node.js core API is built around an idiomatic asynchronous
event-driven architecture in which certain kinds of objects (called
"emitters") periodically emit named events that cause Function objects
("listeners") to be called.
Source:
https://nodejs.org/api/events.html#events_passing_arguments_and_this
_to_listeners
20
![Page 21: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/21.jpg)
What is Node.js?
5. Event-driven
21
![Page 22: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/22.jpg)
What is Node.js?
5. Event-driven
Source: http://abdelraoof.com/blog/2015/10/28/understanding-nodejs-event-loop
22
![Page 23: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/23.jpg)
Asynchronous programming
23
Must read: http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function
![Page 24: Asynchronous programming in Node - MathUniPDtullio/IS-1/2016/Seminari/Async.pdf · What is Node.js? 5. Event-driven Much of the Node.js core API is built around an idiomatic asynchronous](https://reader034.vdocuments.site/reader034/viewer/2022042919/5f60581f8c2e1d2150525e61/html5/thumbnails/24.jpg)
ExamplesCode could be found here:
https://github.com/alemhnan/SWE.UNIPD
24