본문 바로가기
[coroutine] exception 을 이해해보자 #1 ( in my coroutine scope ) -이 글은 coroutine exception 에 대한 일종의 심화과정이라고 볼 수 있다.기본 exception 에 대한 내용을 먼저 이해한 후 이곳의 글을 보자![coroutine] Exception handling -class MainActivity : Activity() { private val coroutineScope = CoroutineScope(Dispatchers.Main) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) findViewById(R.id.btn).setOnClickListener { try { co.. 2019. 3. 5.
[coroutine] Exception handling Exception propagation - Coroutine builder 는 2가지 flavor 가 있다. exception 을 자동으로 전파하는 launch, actor류. 그리고 user 에게 노출되는 async, produce 류. 자동 전파하는 케이스는 Java 의 uncaughtExceptionHandler 와 비슷하게 unhandled exception 이다. 반면에 user 에게 노출되는 경우는 user 가 exception 을 직접 handle 할 수 있다. (돼왕: try-catch 할 수 있다.) 대표적 api 는 await 와 receive 가 있다. - runBlocking{ val job = GlobalScope.launch{ println(“Throwing exception f.. 2019. 3. 4.
[Coroutine] Coroutine context and dispatchers https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/coroutine-context-and-dispatchers.md#thread-local-data -기존에 있었던 doc 이 update 되어서 따로 정리한다. Coroutine context and dispatchers -Coroutine 은 항상 어떤 context 하에서 실행된다.이 context 는 CoroutineContext type 을 가지며 Kotlin standard lib 에 정의되어 있다. -Coroutine context 는 여러개의 element 들을 가진 set 이다.main element 는 coroutine 의 Job, dispatcher 이다. Dispatchers.. 2019. 2. 8.
[Kotlin] Coroutine 소개 (그렇지만 조금 깊을 수도 있음..) [Kotlin] Coroutine 소개 https://www.slideshare.net/elizarov/introduction-to-kotlin-coroutines -Coroutine 개념은 아주 오래된 녀석이다.Simula 67 이란 언어에서 처음으로 소개된 개념이다. detach : suspension statement resume : resume coroutine execution -Coroutine 은 multithreading 이 나오면서 잠시 out 되어있었다.그러나 최근에 async code 가 많이 사용되면서 다시 주목받기 시작했다. -Thread 는 resource 측면에서 high-load 이며,single thread 만 지원하는 언어들도 있으며,mutable state 가 많고, U.. 2018. 11. 27.
[Kotlin] Coroutines tutorial - async code 쉽게 짜기 [Kotlin] Coroutines tutorial - async code 쉽게 짜기 https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md -Kotlin coroutines 는 async code 를 sync code 의 구조를 바꾸지 않고 짤 수 있게 도와준다. Coroutine Basics - modified내용이 바뀌어서 새로 정리하였습니다. -> Coroutine Basics ( 코루틴 기초 ) 예전 기록을 보고 싶으시면 아래 "더보기" 버튼을 눌러주세요!Hello World Coroutine -launch{ delay(1000L) println(“World!”)}println(“Hello,”)Thread.slee.. 2018. 11. 25.
[ios 10] CallDirectory  beginRequestWithExtensionContext 이야기 [ios 10] CallDirectory beginRequestWithExtensionContext 이야기 -beginRequestWithExtensionContext 함수에서 context 에 complete 혹은 cancel 을 날려야 제대로 해당 function 이 끝난다.만약 둘 중 하나를 불러주지 않으면 system setting 에서 해당 값이 켜지거나 꺼지지 않는다. -system setting 에서 값을 Off 할 때는 불리지 않고, On 할 때는 해당 함수가 불린다.Main Process 가 Kill 되어있어도 상관없다. -해당 함수에서는 complete 나 cancel 을 바로 불러줘야 하기 때문에async 로 무언가를 수행하기 어렵다. ( iPhone5 로 테스트 했을 때 5초 넘는 .. 2018. 2. 9.
[iOS Study] 병렬 프로그래밍 가이드 ( dispatch source ) [iOS Study] 병렬 프로그래밍 가이드 ( dispatch source ) https://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html#//apple_ref/doc/uid/TP40008091-CH103-SW1 About dispatch source -dispatch source 는 low-level system event 를 처리하기 위한 data type 이다. -Timer dispatch source 는 주기적인 noti 를 만든다. -Signal dispatch source 는 UNIX signal 이 도착하면 not.. 2017. 7. 3.
Android Loaders Tutorial Android Loaders Tutorial http://developer.android.com/guide/components/loaders.html Android 3.0 부터 Loader 가 등장하여 async 하게 data 를 load 할 수 있게 되었다.Loader 는 다음과 같은 특징이 있다. - Activity, Fragment 에서 접근 가능하다.- Data 를 async 하게 load 한다.- Source data 를 monitor 하면서 내용이 변경되면 새로운 결과를 전달한다.- config change 등과 같은 activity, fragment 의 recreation 시 기존 자료를 자동으로 reload 한다. Loader API Summary LoaderManager Activity .. 2015. 11. 3.
Groovy 언어에 대해 살짝 알아보자~ Groovy 언어에 대해 살짝 알아보자~ IOS 8 부터 Object-C 를 버리고 Swift라는 새로운 언어를 선택했듯.. ( 아직 완전히 버린 건 아니고 혼재해서 사용하지만.. )안드로이드 혹은 자바 진영에서도, 더 짧게 언어를 쓰기 위해 Groovy 라는 언어를 채택하려는 움직임들이 일고 있다. public class FeedActivity { TextView mTextView; ... void updateFeed() { new FeedTask().execute("http://path/to/feed"); } class FeedTask extends AsyncTask { protected String doInBackground(String... params) { DefaultHttpClient htt.. 2015. 2. 20.
반응형