boseok-note
  • README
  • javascript
    • 함수형 자바스크립트
    • core
      • 이벤트루프 (Event Loop)
      • boxing, unboxing
      • prototype
      • 실행컨텍스트
      • hoisting
      • 클로져(Closure)
      • arguments
      • Scope - 스코프 - 유효범위
    • api
      • Promise
      • Fetch API
      • worker-api
      • Web API
    • lib
      • rxjs
        • rxjs
    • 호스트객체?
    • es6
      • var-let-const
      • template-literals
      • async-await
    • tip
      • array-like
      • Object literal, new Object
    • dom-api
      • HTML Element get Text
      • get-size
      • scrollToBottom
    • for in, for of 차이
    • storage
    • Constructor (생성자)
    • Javascript
    • module
  • front-end
    • vuejs
      • vue-rx
      • README
        • 1-start
        • 2-basic-component
        • 3-add-component
        • 4-advanced-component
        • 5-dynamic-methods-event
        • 6-internal-process
      • next-tick
      • compare-react
      • v-model-with-props
      • v-for
      • vuejs
      • vuex
    • browser
      • dom
      • cssom
      • reflow, repaint
      • 렌더링 트리(Rendering Tree)
      • web-standard
    • css
      • text-ellipse
      • white-space
      • css layout
    • Pre-render
    • react-native
      • react-native
    • 최적화 관련
    • reactjs
      • performance
      • reactjs
    • CSR, SSR
  • server-side
    • letsencrypt
    • auto-deploy
    • nlb
    • Certbot, aws https setting with wildcard
    • mysql
    • node.js
      • npm
        • npm install
      • node-dynamodb
      • node에서 간편하게 letsencrypt를 사용하여 https 구현하는 방법
    • Docker
    • nginx
    • Amazon Web Service
    • nginx https 설정
  • design-pattern
    • observer
    • flux
    • README
  • coop
    • git
      • gitignore
      • remote
      • ssh key 사용하기
      • password
      • credential
      • git
  • cs
    • port
    • data-structure
      • tree
      • binary-tree
    • network
      • home-router
      • tcp-udp
      • http
    • process
  • etc
    • sync-async
    • seo
      • seo
      • SEO Check Point
    • rest
    • unity
      • methods
Powered by GitBook
On this page
  1. javascript
  2. core

이벤트루프 (Event Loop)

js는 싱글스레드인데 동시에 많은 이벤트들을 어떻게 처리할까?

이벤트루프는 js의 메인스레드이고 싱글스레드이다.

이벤트루프는 콜스택과 태스크큐를 지켜보고있다가 콜스택이 비어있으면

태스크큐에서 첫번째 이벤트를 콜스택에 넣어주는 일을하고, 그것을 tick이라고한다.

콜 스택이 비어 있고 태스크 큐에 콜백 함수가 있는 경우, 함수는 큐에서 제외되고 실행될 콜 스택으로 푸시됩니다.

이벤트루프는 ECMAScript의 스펙이 아니다. 구동 환경측에서 구현해야한다.

그래서 노드는 비동기 io를 지원하기 위해 libuv라이브러리를 사용하는것이다.

브라우저도 마찬가지로 자바스크립트 엔진외에 별도 구현체가 있을것이다.

이 말은 자바스크립트 엔진은 하나의 콜스택만 사용한다는 뜻이다.

결국 자바스크립트는 싱글스레드이므로 block되는 코드가 존재한다면 그냥 block된다.

PreviouscoreNextboxing, unboxing

Last updated 6 years ago