官术网_书友最值得收藏!

Chapter 2. The JavaScript Execution Model

The first chapter of this book explored the state of JavaScript concurrency. Generally speaking, dealing with concurrency in JavaScript applications is anything but a trivial matter. There's a lot to think about when writing concurrent JavaScript code, and the kind of solutions that we come up with are often unorthodox. There's a lot of callbacks, and wading through all of them is enough to drive a person insane. We also caught a glimpse of how our pattern of writing concurrent JavaScript code has started to change with existing concurrency components. Web workers have started to mature, and JavaScript language concurrency constructs have only just been introduced.

The language and the runtime environment only get us partway there. We need to think about concurrency at the design level, rather than after the fact. Concurrency should be the default. This is easy to say and very difficult to do. Throughout this book, we're going to explore all that the JavaScript concurrency features have to offer, and how we can best use them to our advantage as design tools. But, before we do this, we need to go into depth on what's really happening when our JavaScript runs. This knowledge is an essential input to designing concurrent applications, because we'll know exactly what to expect when choosing one concurrency mechanism over another.

In this chapter, we'll start with the browser environment, by looking at all the subsystems that our code touches—such as the JavaScript interpreter, the task queue, and the DOM itself. Then we'll walk through some code that will shed some light on what's really happening behind the scenes to orchestrate our code. We'll close the chapter with a discussion on the challenges that we face with this model.

主站蜘蛛池模板: 米脂县| 丽江市| 芦溪县| 荆州市| 两当县| 阿拉善左旗| 巫山县| 鄂温| 九江市| 翁源县| 英德市| 泾阳县| 天祝| 东城区| 贺兰县| 永仁县| 延吉市| 宁德市| 遂平县| 祁东县| 商都县| 泽普县| 罗山县| 涡阳县| 扎赉特旗| 个旧市| 密山市| 遵义县| 德兴市| 鄂伦春自治旗| 承德县| 清徐县| 江安县| 南通市| 泾川县| 嘉兴市| 金秀| 夹江县| 巴林左旗| 安顺市| 阿克陶县|