Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCD QoS #126

Closed
Youngminah opened this issue Jan 12, 2022 · 0 comments
Closed

GCD QoS #126

Youngminah opened this issue Jan 12, 2022 · 0 comments
Labels

Comments

@Youngminah
Copy link
Owner

Youngminah commented Jan 12, 2022

읽기전에



GCD QoS (Quality of Service)

image

  • 대기큐에 연결할 서비스 품질 수준 = 우선순위
  • userInteractive: 가장 높은 우선순위. 애니메이션, 이벤트 처리, UI 갱신 등 사용자와의 상호작용.
  • userInitiated: 두번째로 높은 우선순위. 빠른 반응 속도가 필요하거나, 유저가 앱에 기대하는 핵심 정보를 로딩할 때 사용.
  • default: 세번째로 높은 우선 순위이자 기본 값. 앱 초기화 혹은 유저를 대신해 수행하는 작업에 사용.
  • utility: default보다 한단계 낮은 우선순위. 바로 완료되지 않아도 앱사용에 지장이 없는 부가적인 작업에 사용.
  • background: 가장 낮은 우선순위. 앱이 백그라운드 상태로 갔을 때 할 작업 등에 사용.

예제

@IBAction func globalQos(_ sender: UIButton) { 
    
    DispatchQueue.global(qos: .background).async {
        for i in 1...50 {
            print(i, terminator: " ")
        }
        print("\nBackground 완료")
    }
    
    DispatchQueue.global(qos: .userInteractive).async {
        for i in 51...100 {
            print(i, terminator: " ")
        }
        print("\nUserInteractive 완료")
    }
    
    DispatchQueue.global(qos: .utility).async {
        for i in 101...150 {
            print(i, terminator: " ")
        }
        print("\nUtility 완료")
    }
}
  • UserInteractive 완료 > Utility 완료 > Background 완료 순으로 완료되었음.

출력결과

image







참고자료

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant