Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PromiseとAsync-Awaitまとめ(Emacsで)
Search
Takashi Masuda
November 10, 2017
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PromiseとAsync-Awaitまとめ(Emacsで)
フィードフォースの社内LT大会で発表しました
Takashi Masuda
November 10, 2017
More Decks by Takashi Masuda
See All by Takashi Masuda
マスタカネットの紹介 〜悠久なる変更履歴〜
masutaka
0
19
最近の情報収集方法 2025
masutaka
0
98
自分のブログをCloudFront+HerokuからCloud Runに移行した
masutaka
0
190
BigQuery経由で使うGoogleスプレッドシートのスキーマ管理
masutaka
0
380
本を聴く毎日を送っています
masutaka
0
110
ボッチLookML開発者兼データ整備人を連れてきたよ!
masutaka
0
150
ここがつらいよ普段使いのLinux
masutaka
0
390
4月から取り組んできたLookerの導入から実装までのお話
masutaka
0
200
HerokuでSidekiqを監視する方法を確立した
masutaka
0
670
Other Decks in Programming
See All in Programming
SREの越境 / SRE Collaboration
y0hgi
2
290
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
560
Security issues being discussed on Web Platforms
petamoriken
0
1.3k
Verilogで学ぶCPU自作入門.pdf
uyuki234
8
3.7k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
590
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
420
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
140
FreeBSDでZabbixを動かす
kenkino
0
340
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
560
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
4.7k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
490
Featured
See All Featured
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
250
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
290
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
780
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
530
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
540
Building Adaptive Systems
keathley
44
3.2k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
340
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Transcript
1SPNJTFͱ "TZOD"XBJU·ͱΊ !NBTVUBLB
w օ͞Μ͝ଘͷ௨Γɺ&NBDTͰඇಉظ ॲཧΛ࣮ݱ͢ΔͨΊʹɺ5$1ίωΫ γϣϯΛ։͔͘ɺ֎෦ίϚϯυΛىಈ ͢Δඞཁ͕͋Γ·͢
֎෦ίϚϯυΛىಈ͢Δ
w ΤσΟλͰԿ͔ॻ͍͍ͯΔ࣌ɺόοΫάϥϯ υͰԿ͔ͨ͘͠ͳΓ·͢ΑͶʁ w ྫ͑ɺ(JU)VCͰ4UBSͨ͠ϦϙδτϦͯϒ ͨ͠63-ΛΤσΟλ͔Β։ͨ͘ΊɺΩϟογϡ ϑΝΠϧΛDVSMͰఆظతʹ࡞Δͱ͔
ಉظॲཧͭΒ͍ (defun mstk-start-sync () (call-process "sh" nil nil nil "-c"
"sleep 3; echo OK") (message-box "mstk-start-sync finished.")) (mstk-start-sync) 3ඵؒԿग़དྷͣʹɺ Emacs͕ݻ·Δɻ
ඇಉظॲཧͭΒ͍ (defun mstk-start-async-1a () (setq proc (start-process "mstk-start-async-1a" (generate-new-buffer "
*sh*") "sh" "-c" "sleep 3; echo OK")) (set-process-sentinel proc 'mstk-async-sentinel-1a)) (defun mstk-async-sentinel-1a (_process _event) (message-box "mstk-start-async-1a finished.")) (mstk-start-async-1a) Emacsݻ·Βͳ͘ͳΔ͕ɺ sentinelʢ൪ฌʣؔඞཁ
ඇಉظॲཧͭΒ͍ (defun mstk-start-async-1b () (setq proc (start-process "mstk-start-async-1b" (generate-new-buffer "
*sh*") "sh" "-c" "sleep 3; echo OK")) (set-process-sentinel proc (lambda (_process _event) (message-box "mstk-start- async-1b finished.")))) (mstk-start-async-1b) lambdaͰؔఆٛ লུͰ͖Δ
ඇಉظॲཧͭΒ͍ (defun mstk-start-async-2b () (make-process :name "mstk-start-async-2b" :buffer (generate-new-buffer "
*sh*") :command '("sh" "-c" "sleep 3; echo OK") :sentinel (lambda (_process _event) (message-box "mstk-start- async-2b finished.")))) (mstk-start-async-2b) make-process͏ͱ ͍ͣͿΜεοΩϦ͢Δɻ ͱ͜ΖͰԿͬͯͨΜ͚ͩͬʁ
֎෦ίϚϯυΛඇಉظͰ ࣮ߦ͍͚ͨͩ͠ͳͷʹʂ
FNBDTQSPNJTF https://github.com/chuntaro/emacs-promise
QSPNJTF (require 'promise) (defun mstk-start-promise-1a () (promise-chain (promise:make-process "sh" "-c"
"sleep 3; echo OK") (then (lambda (reason) (message-box "then %s" reason))))) (mstk-start-promise-1a) ಡΈ͍͢ɾɾɾͷ͔ʁ
QSPNJTF Τϥʔॲཧ (require 'promise) (defun mstk-start-promise-2a () (promise-chain (promise:make-process "sh"
"-c" "sleep 3; echo OK") (then (lambda (reason) (/ 1 0) ;; an error occurs!! (message-box "then %s" reason))) (promise-catch (lambda (reason) (message-box "catch error!! %s" reason))) (done (lambda (reason) (message-box "done. %s" reason))))) (mstk-start-promise-2a) ͔Γ͍͢ɾɾɾʁ
FNBDTBTZODBXBJU https://github.com/chuntaro/emacs-async-await
BTZODBXBJU (require 'async-await) (setq lexical-binding t) (async-defun mstk-start-async-await-1a () (await
(promise:make-process "sh" "-c" "sleep 3; echo OK")) (message-box "finish")) (mstk-start-async-await-1a) ͖ͬ͢Γ͠ਿ
BTZODBXBJU Τϥʔॲཧ (require 'async-await) (setq lexical-binding t) (async-defun mstk-start-async-await-2a ()
(condition-case reason (progn (await (promise:make-process "sh" "-c" "sleep 3; echo OK")) (/ 1 0) ;; an error occurs!! (message-box "finish")) (error (message-box "catch error!! %s" reason)))) (mstk-start-async-await-2a) Τϥʔॲཧ͍ͭͲ͓Γʂ
σϞ
ॴײ w ҎલΑΓඇಉظॲཧͷ໘ष͞গͳ͘ͳͬ ͨͱײͨ͡ w γϯλοΫεΛఆٛͰ͖Δݴޠɺදݱͷࣗ༝ ͕ߴ·Δ w -JTQσʔλؔશ෦4ࣜͰදݱͰ͖Δɻඒ ͍͠
એ w IUUQTHJUIVCDPNNBTVUBLBFNBDTIFMN IBUFOBCPPLNBSL w IUUQTHJUIVCDPNNBTVUBLBFNBDTIFMNRJJUB w BTZODFMͬͨΒIFMNHJUIVCTUBSTFMΛมߋ ͤͣʹඇಉظԽͰ͖ͨIUUQTNBTVUBLBOFU DIBMPXIUNM
4QFDJBM5IBOLT w ஜࢵ"ؙΰγοΫʢຊจʣ w .FOMPʢίʔυʣ w IJHIMJHIUʢίʔυϋΠϥΠτʣ w IJHIMJHIU0SUGIPHFFMcQCDPQZ http://kakakakakku.hatenablog.com/entry/2017/05/30/092247