Programming/iOS

[iOS]Dispatch Queue

lingk 2020. 10. 14. 21:43

Dispatch

Execute code concurrently on multicore hardware by submitting work to dispatch queues managed by the system.

 

๐Ÿ‘‰์‹œ์Šคํ…œ์—์„œ ๊ด€๋ฆฌํ•˜๋Š” ๋””์ŠคํŒจ์น˜ ํ์—๊ฒŒ work๋ฅผ ์ œ์ถœํ•˜์—ฌ, ๋ฉ€ํ‹ฐ์ฝ”์–ด ํ•˜๋“œ์›จ์–ด์—์„œ ์ฝ”๋“œ๋ฅผ ๋™์‹œ์ ์œผ๋กœ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

 

๐Ÿ‘‰GCD์—์„œ Distpatch Queue๋ฅผ ์ œ๊ณตํ•ด์ฃผ์–ด ์•ˆ์ „ํ•œ ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋”ฉ์ด ๊ฐ€๋Šฅ

 

Queue (ํ)โ“

์ปดํ“จํ„ฐ์˜ ์ž๋ฃŒ๊ตฌ์กฐ ์ค‘ ํ•˜๋‚˜๋กœ, FIFO(First In First Out)๊ตฌ์กฐ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•œ๋‹ค.

 

 

 

โœ”๏ธmain(serial)

main ์Šค๋ ˆ๋“œ์—์„œ ์ฒ˜๋ฆฌ๋˜๋Š” serial ํ

ํ•˜๋‚˜์˜ ์ž‘์—…์ด ๋๋‚˜์•ผ ๋˜ ๋‹ค๋ฅธ ์ž‘์—…์„ ์‹œ์ž‘ํ•˜๋Š” ์ง๋ ฌ ๊ตฌ์กฐ

 

 

โœ”๏ธglobal(concurrent)

๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋”ฉ์œผ๋กœ ์ „์ฒด ์‹œ์Šคํ…œ์— ๊ณต์œ ๋˜๋Š” concurrent ํ

๋™์‹œ์— ์—ฌ๋Ÿฌ ์ž‘์—…์„ ํ•˜๋Š” ๋ณ‘๋ ฌ ๊ตฌ์กฐ

class func global(qos: DispatchQoS.QoSClass = .default) -> DispatchQueue

ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” qosโ—๏ธQoS (Quality of Service)๋Š” DispatchQueue์—์„œ ์ˆ˜ํ–‰ ํ•  ์ž‘์—…์„ ๋ถ„๋ฅ˜ํ•˜์—ฌ ์ค‘์š”๋„์™€ ์šฐ์„ ์ˆœ์œ„์— ๋”ฐ๋ผ์„œ User-interactive, User-initiated, Utility, Background ๋„ค๊ฐœ๋กœ ๊ตฌ๋ถ„๋œ๋‹ค

 

 

 

 

๋ฐ˜์‘ํ˜•