관리 메뉴

IT 컴퓨터공학 자료실

Event-Driven Programming에 대해 본문

etc.. 기타 카테고리 2/영어 번역 & 일본어 번역

Event-Driven Programming에 대해

윤맨1 2015. 7. 14. 19:10

In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs/threads. Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g. JavaScript web applications) that are centered on performing certain actions in response to user input.

 

컴퓨터공학에서, Event-driven programming은 이벤트에 의해 프로그램의 흐름이 결정되는 프로그래밍 패러다임이다. 이벤트는 유저의 action (마우스 클릭, 키 누르기)이나 센서의 output, 다른 프로그램이나 스레드의 메시지를 말한다. Event-driven programming은 그래픽 유저 인터페이스와 사용자에 입력을 받아 수행되는 것이 주된 목적인 어플리케이션에서 사용되는 저명한 패러다임이다.

 

In an event-driven application, there is generally a main loop that listens for events, and then triggers a callback function when one of those events is detected. In embedded systems the same may be achieved using hardware interrupts instead of a constantly running main loop. Event-driven programs can be written in any programming language, although the task is easier in languages that provide high-level abstractions, such as closures.

 

Event-driven programming의 패러다임으로 만들어진 어플리케이션에서는, 보통 이벤트를 받아들이는 메인 루프가 있고, 어느 이벤트가 발생했을 때 콜백 function을 발생시킨다. 임베디드 시스템에서는 메인루프를 이용하는 것 대신에 하드웨어 인터럽트로 이와 같은 기능을 구현한다. Event-driven programtaskclosure같은 추상적인 고레벨 언어라 할지라도, 어떠한 프로그래밍 언어든 간에 표현이 가능하다.

 

best practice

모범사례

 

Event-driven programming is widely used in graphical user interfaces, for instance the Android concurrency frameworks are designed using the Half-Sync/Half-Async pattern, where a combination of a single-threaded event loop processing (for the main UI thread) and synchronous threading (for background threads) is used. This is because the UI-widgets are not thread-safe, and while they are extensible, there is no way to guarantee that all the implementations are thread-safe, thus single-thread model alleviates this issue.

 

event-driven programmingGUI환경에서 널리 쓰인다. 예를 들면 현재 우리가 쓰는 프레임워크인 안드로이드가 그 예다. 안드로이드는 Half-Sync/Half-Async pattern을 사용해 고안되었으며, 단일-스레드로 구성된 이벤트 루프가 프로세싱되며 (메인 UI 스레드에), 동기화 스레드가 사용되고 있다(background 스레드에). 이런 구조는 UI-위젯이 스레드에 안전하지 않은 반면에 이것들이 확장가능하기 때문이다. 모든 코드들에서 스레드의 안전을 지키는 것은 불가능했기에, 단일 스레드 모델의 출현은 이러한 문제점을 해소시켰다.

 


출처 : https://en.wikipedia.org/wiki/Event-driven_programming