Skip to content

Instantly share code, notes, and snippets.

View ElonPark's full-sized avatar
📱
 iOS Software Engineer

Elon Park ElonPark

📱
 iOS Software Engineer
View GitHub Profile
@ElonPark
ElonPark / libdispatch-efficiency-tips.md
Created October 16, 2025 16:34 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@ElonPark
ElonPark / writing.md
Created August 2, 2022 11:39 — forked from longfin/writing.md
엔지니어를 위한 글쓰기

이 글은 Heinrich Hartmann 님이 작성하신 글을 한국어로 번역한 것입니다. 원문은 https://www.heinrichhartmann.com/posts/writing/ 에서 확인하실 수 있습니다.


글쓰기는 큰 조직에서 영향력을 발휘하는 데 중요합니다. 경력 있는 소프트웨어 엔지니어로서의 글쓰기는 직무 범위를 확장하고 경력을 발전시키기 위해 획득해야 하는 가장 중요한 기술입니다.

글쓰기는 어렵습니다. 많은 소프트웨어 엔지니어들이 글쓰기와 씨름하죠. 저도 개인적으로 문학에 대한 관심이 없기 때문에 글쓰기가 자연스럽지 않았습니다.

//: Playground - noun: a place where people can play
import Foundation
import UIKit
import Darwin.os.lock
/**
A threadsafe, non-blocking (on the write side), zero-allocation ring-buffer implementation.
@ElonPark
ElonPark / bindListener.swift
Created July 29, 2021 03:13
bind Listener
// MARK: - Binding
private extension UserListViewController {
func bind(listener: UserListPresentableListener?) {
guard let listener = listener else { return }
bindActions(to: listener)
bindState(from: listener)
}
}
@ElonPark
ElonPark / transformMutation.swift
Last active August 16, 2021 13:18
routing call
// MARK: - transform mutation
func transform(mutation: Observable<Mutation>) -> Observable<Mutation> {
return mutation
.withUnretained(self)
.flatMap { this, mutation -> Observable<Mutation> in
switch mutation {
case .attachUserInformationRIB:
return this.attachUserInformationRIBTransform()
@ElonPark
ElonPark / UserListInteractor.swift
Created July 29, 2021 03:01
UserListInteractor impl Reactor protocol
// MARK: - UserListInteractor
final class UserListInteractor:
PresentableInteractor<UserListPresentable>,
UserListInteractable,
UserListPresentableListener,
Reactor
{
/* ... */
}
@ElonPark
ElonPark / UserListPresentableListener.swift
Created July 29, 2021 02:56
UserListPresentableListener without ReactorKit
// MARK: - UserListPresentableListener
protocol UserListPresentableListener: AnyObject {
typealias Action = UserListPresentableAction
typealias State = UserListPresentableState
func sendAction(_ action: Action)
var state: Observable<State> { get }
var currentState: State { get }
}
@ElonPark
ElonPark / UserListViewController.swift
Created July 29, 2021 02:52
UserListViewController.swift
// MARK: - UserListPresentableAction
enum UserListPresentableAction {
case loadData
case refresh
case loadMore(IndexPath)
case itemSelected(IndexPath)
}
// MARK: - UserListPresentableListener
@ElonPark
ElonPark / UserListInteractor.swift
Last active August 16, 2021 13:18
UserListInteractor
// MARK: - UserListInteractor
final class UserListInteractor:
PresentableInteractor<UserListPresentable>,
UserListInteractable,
UserListPresentableListener,
Reactor
{
// MARK: - Reactor
@ElonPark
ElonPark / ProfileViewReactor.swift
Created July 29, 2021 02:43
ProfileViewReactor
class ProfileViewReactor: Reactor {
// represent user actions
enum Action {
case refreshFollowingStatus(Int)
case follow(Int)
}
// represent state changes
enum Mutation {
case setFollowing(Bool)