concurrent.el ãªãªã¼ã¹
ä»ã¾ã§ä½ã®èª¬æãç¡ãã«èªåã®ã¢ããªã§ä½¿ã£ã¦ããè¬ã©ã¤ãã©ãª concurrent.el ã§ãããä¸åºåããä»ããæ°ããã¾ããã®ã§ãªãªã¼ã¹ãããã¨æãã¾ãã
ãã®è¨äºã§ã¯ concurrent.el ã®åºç¤ã§ãã deferred.el ã«ã¤ãã¦ç°¡åã«ç´¹ä»ãã¦ã concurrent.el ã®æ©è½ã¨é©ç¨ä¾ãç´¹ä»ãã¾ãã
ãããã
- deferred.el復ç¿
- concurrent.elç´¹ä»
- æ©è½ä¸è¦§ãã³ã¼ãä¾
- cacoo.elã§ã®è¨è¨è§£èª¬
deferred.el ç´¹ä»
deferred.el ã®è©³ãã使ãæ¹ãAPIãªã©ã¯READMEã®ææ¸ãã¾ã¨ã¾ã£ã¦ãã¾ãã®ã§ãæã£åãæ©ã使ããã人ã¯ãã¡ããåç §ãã¦ã¿ã¦ãã ããã ãããããä»ã®è¨èªã§Deferredã«æ £ãã¦ããã°ããã«ä½¿ããã®ã§ã¯ãªããã¨æãã¾ãã
- deferred.el リリース - 技術日記@kiwanami ï¼ãªãªã¼ã¹è¨äºï¼æ £æ§ã¹ã¯ãã¼ã«ãã¡ã¤ã³ããï¼
- deferred.el の README ï¼ç°¡åãªã³ã¼ãä¾ãé¢æ°ãªãã¡ã¬ã³ã¹ãªã©ï¼
- deferred.el のできるまで:調査、設計と実装 - 技術日記@kiwanamiï¼ä¸è¬çãªãDeferredãã«ã¤ãã¦ã®æ å ±ããããï¼
Deferred / éåæã¿ã¹ã¯ãã¤ãªãã¦ãã
deferred.el ã¯éåæã®ã¿ã¹ã¯ãã¤ãªãã¦ããããã°ã©ã ãã¤ãã£ã¦ããã¾ããå ·ä½çã«ã¯ããããã³ã¼ã«ããã¯ï¼ããå®è¡ããå¾ã§ãã³ã¼ã«ããã¯ï¼ããå®è¡ããã¨ãããããªãã³ã¼ã«ããã¯ã®é£éãæ§ç¯ãã¾ããæ¸ãã¦ããããã°ã©ã ã¯ã³ã¼ã«ããã¯ã®ã¤ãªãæ¹ãæ示ãããããªããã°ã©ã ã«ãªãã¾ãã
ã¤ã¾ãã³ã¼ã«ããã¯ã®æ¸ãæ¹ãå°ãå¤ããã ããªã®ã§ãããã½ã¼ã¹ã³ã¼ããæ ¼æ®µã«åããããããªããã¾ãéåæãã¤ãªããã¨ãã®æè»æ§ãã¯ããã«åä¸ãã¾ããã¾ããã¨ã©ã¼æã®å¦çãåããããããããªãæ¸ããã¨ãåºæ¥ããããããã°ã©ã ã®ä¿¡é ¼æ§ãä¸ããã¾ãã
JavaScriptä¸ã®å®è£ ã§ãã JSDeferred ãåèã«å®è£ ãã¦ãã¾ãã®ã§ããã¡ãã«ãªãã¦ãã人ã¯ããã«ä½¿ããã¨æãã¾ããã¾ããJavaScriptããããã¨5年以ä¸å¾çºã§ãããããåºæ¬APIã¯æ¯ãã¦ãã¦ããªãåºã¾ã£ã¦ãã¾ãããããããä»å¾ãæ©è½è¿½å ã¯ãã£ãã¨ãã¦ãéäºæãªä¿®æ£ã¯ã»ã¨ãã©ç¡ãã ããã¨æã£ã¦ãã¾ãã
åºæ¬æ©è½ä¸è¦§
ç°¡åã«æ©è½ãç´¹ä»ãã¾ãã
éåæã¿ã¹ã¯ã®éå§ | |
---|---|
ããã«éå§ | deferred:next |
ä¸å®æéå¾ ã£ã¦éå§ | deferred:wait |
è¤æ°ã®ã¿ã¹ã¯ã並è¡ã«éå§ | deferred:parallel, earlier |
ãªã¹ããæ°ãåãåã£ã¦ã«ã¼ãéå§ | deferred:loop |
åæçã«éå§ | deferred:succeed |
å¤é¨ããã»ã¹ãéå§ | deferred:process ãªã© |
HTTPæ¥ç¶ãéå§ | deferred:url-retrieve ãªã© |
ã¿ã¹ã¯ãã¤ãªã | |
---|---|
åã®ã¿ã¹ã¯ã«ã¤ãªã | deferred:nextc |
ã¨ã©ã¼æã®ã¿ã¹ã¯ãã¤ãªã | deferred:error |
åçã«ã¤ãªã | ã¿ã¹ã¯ã®è¿å¤ã§æ¬¡ã«å®è¡ãããDeferredãªãã¸ã§ã¯ããè¿ã |
æ£å¸¸ã»ã¨ã©ã¼ã«ãããããã¿ã¹ã¯ãå²ãè¾¼ã¾ãã | deferred:watch |
éåæã§ã®try-catch-finally | deferred:try |
å¾ ã¡åãã | |
---|---|
並è¡ã¿ã¹ã¯ãå ¨é¨çµäºããã¾ã§å¾ 㤠| parallel |
æ©ãçµäºããä¸ã¤ã®ã¿ã¹ã¯ã ããå¾ ã¤ | earlier |
æ´»ç¨ä¾
èªåãã¼ã«ã§ã¯çµæ§ä½¿ã£ã¦ãã¾ããä»å¾ãå¿ é ã«ãªãã¨æã£ã¦ãã¾ãã
- deferred.elã®ã¿
- concurrent.elã¨ä¸ç·ã«
deferred.elのリリース時ã«ãå°ãç´¹ä»ãããã¾ããããèªå以å¤ã®æ¹ãèå³ãæã£ã¦ããã ããã¿ããã§ããããã§ãã
éåæã§æ¬²ãããªããã®
é常ã«ä¾¿å©ãª Deferred ãªã®ã§ããã æ £ãã¦ããã¨å¦çãåã£ããã¤ãªãããã¨ããããªãä½ã¬ãã«ãªå¦çãç¶ããã¨ã«æ°ãã¤ãã¾ããã¾ããå¤ãã®å ´é¢ã§ä¼¼ããã㪠Deferred å¦çãæ¸ããã¨ãå¤ããªã£ã¦ãã¾ããã
ã©ã®ãããªå ´åãããã®ãã¾ã¨ãã¦ã¿ã¾ããã
- éåæããã»ã¹æ°ã®å¶å¾¡
- wgetãconvertãªã©ã®åæå®è¡æ°ãå¶éããã
- ããã¯ãå¦çãç´ååããã
- âããã¯ãã»ããã©
- å®è¡é åºã®å¶å¾¡
- è¤æ°ã®ã¿ã¹ã¯ãéåæã«å®è¡ãããããé åºãä¾åé¢ä¿ã§å¶å¾¡ããã
- âãã¼ã¿ããã¼
- ã¹ã¬ãã
- UIã«ã¢ãã¡ã¼ã·ã§ã³ãæ軽ã«å ¥ããã
- ããã¯ã°ã©ã¦ã³ãã§å¦çãå°å»ã¿ã«è¡ããã
- éåæããã»ã¹éã®éä¿¡
- Windowããããã¡éã§éä¿¡ããã
- ã§ãä¾åé¢ä¿ãå¢ãããããªã
- âéåæéä¿¡
- GUIã§ããããã¤ãã³ã管çã·ã¹ãã ã欲ãã
- Emacsã®ã¤ãã³ãã¯ããªããã£ãéãã
- èå³ããã¤ãã³ã
- ããã¼ããã£ã¹ã
- ã¤ãã³ãã·ã¹ãã ã®é層æ§é
- âã¹ããªã¼ã ããã£ã³ãã«
- Windowããããã¡éã§éä¿¡ããã
ãããããããã¯Emacsã ãã®åé¡ã§ã¯ãªãã¦ãéåæããããã使ãå ´åã«ã¯ã¿ããªåãæ©ã¿ãæã£ã¦ããã®ã§ã¯ãªããã¨æãã¾ãã
ãã㧠deferred.el ã®ä¸ã«ãä¸è¨ã®ãããªè¯ãããæ©è½ãæ§ç¯ãã¦ã¿ã¾ããã
concurrent.el
åºæ¬çã«ã¯ãä¸ã§è¿°ã¹ããããªè¦æ±ãæºãããããªæ©è½ãè¨è¨ã»å®è£ ãã¾ããããã®éãããã¾ã§ã®éçºã®çµé¨ãããã«ãã¹ã¬ããã並è¡ããã°ã©ãã³ã°ã®èãæ¹ãªã©ãåèã«ãã¾ããã
ãã ã並è¡ããã°ã©ãã³ã°ãGUIã®å°é家ã§ã¯ãªãã®ã§ãè¯ãæ¹æ³ããããã°æ¯éç¥ãããã¨æã£ã¦ãã¾ããã concurrent.el ã®å®è£ èªä½ã«ã¤ãã¦ãè°è«ãããã°æãã¦æ¬²ããã¨æã£ã¦ãã¾ããæ¯éã¿ãªãã¾ããããããé¡ããã¾ãã
éçºã¯ deferred.el ã¨åããªãã¸ããªã«å ¥ã£ã¦ãã¾ãã
æ©è½ä¸è¦§
ç¾å¨ã®æ©è½ä¸è¦§ã§ããã³ã¼ããµã³ãã«ã«ã¤ãã¦ã¯ããå¾ã§ä¾ç¤ºãã¾ããï¼Wikipedia便å©ã§ãããï¼
- thread
- é©å½ãªåä½ã§å¦çãåå²ãã¦å®è¡ããã¹ã¬ãã
- generator
- ã¹ã¬ããå®è£ ãã¡ãã£ã¨æ¹å¤ãããã®ããã¾ãã
- ç¡éãã¼ã¿ããfiberã¿ãããªæãã
- semaphore
- ããããã»ããã©
- åæå®è¡æ°ã1ã«ãã¦ãããã¯ãã¡ãã»ã¼ã¸ãã¥ã¼ã¨ãã¦ä½¿ã£ã¦ããããã
- dataflow
- å¤ããã¤ã³ããããã¾ã§å¦çãæ¢ãã¦ããä»çµã¿
- ãã¼ã¿ããã¼ãã¿ã¼ã³ãFutureãã¿ã¼ã³ã®ãããªãã®
- ã¬ã¦ãã£æ¬ã®ãã¼ã¿ããã¼å¤æ°ï¼ä¸¦è¡è«çå¤æ°ï¼ãã¤ã¡ã¼ã¸
- å¤æ°ã¸ã®ã¢ã¯ã»ã¹ãä¸ã® signal ã使ã£ã¦éç¥ã§ãããç¹ã«æªãã¤ã³ãå¤æ°ã¢ã¯ã»ã¹ã®ã¤ãã³ãã¯ã Ruby ã® method_missing ã£ã½ãã¦å¼·åã
- signal/channel
- éåæã¡ãã»ã¼ã¸éä¿¡
- GUIã®ã³ã³ãã¼ãã³ãéã®ã¤ãã³ãã¨ãã¦ä½¿ã£ãããPACã¢ã¼ããã¯ãã£ã§ã®Cã®éä¿¡ãããããªã©
ããã«æããæ©è½ã¯ãããã¤ããã¼ã«ãä½ã£ã¦æ¤è¨¼ãã¦ããã®ã§èªåã®ä¸ã§ã¯ããç¨åº¦åºã¾ã£ã¦ãã¾ãããã ãèªåä¸äººãã使ã£ã¦ãã¾ããã®ã§ãä»å¾ä¿®æ£ãæ©è½è¿½å ãããã°ãäºææ§ãç¶æããªããç©æ¥µçã«è¡ã£ã¦ããããã¨æã£ã¦ãã¾ãã
ã¾ããä»å¾ä»¥ä¸ã®é ç®ã«ã¤ãã¦ãå¿ è¦ã§ããã°å®è£ ãããããªã¨æã£ã¦ãã¾ãã
- ã¢ãã¿
- é 延å®è¡
- ããã»ã¹ééä¿¡ãcomintã®ãµãã¼ã
- å·®åãªã¹ãï¼
ã³ã¼ãä¾
- concurrent-sample.el ï¼ä»¥ä¸ã§ç´¹ä»ãããã®ã¨åçã®å 容ï¼
Theadã®ä¾ï¼lexical-letãè©ä¾¡ããã¨ãã®å ´ã§ã¢ãã¡ã¼ã·ã§ã³ãã¾ããå¼æ°ã®æéã¯ãbodyã®å¦çã®ééã§ãã
(lexical-let ((count 0) (anm "-/|\\-") (end 50) (pos (point))) (cc:thread 60 (message "Animation started.") (while (> end (incf count)) (save-excursion (when (< 1 count) (goto-char pos) (delete-char 1)) (insert (char-to-string (aref anm (% count (length anm))))))) (save-excursion (goto-char pos) (delete-char 1)) (message "Animation finished.")))
whileã使ããã¨ã§ã¹ã¬ãããã«ã¼ãããããã¨ãåºæ¥ã¾ããwhileã®ä¸èº«ã¯ä¸æ°ã«å®è¡ããã¾ãã
ç¡éã«ã¼ããéãå¦çã§Emacsãåºã¾ããªãããã«æ³¨æãã¦ãã ãããããç¡éã«ã¼ãã«çªå ¥ãã¦ãã¾ã£ãããåºã¾ã£ã¦ãã¾ã£ãã deferred:clear-queue ã³ãã³ãã§å復ã§ããå¯è½æ§ãããã¾ãã
Generatorã®ä¾ï¼fib-genã«ã¸ã§ãã¬ã¼ã¿ã¼ãä½ãã¾ããã¸ã§ãã¬ã¼ã¿ã¼çæbodyå ã®yieldé¢æ°ã§å¤ãè¿ãã¾ããéåæãªã®ã§ãããããªãã®ã§ãããã³ã¼ã«ããã¯ã§å¤ãåãåãã¨ããããã¾ãã¡ããç¥ãã¾ããã
(setq fib-list nil) (setq fib-gen (lexical-let ((a1 0) (a2 1)) (cc:generator (lambda (x) (push x fib-list)) ; ã³ã¼ã«ããã¯ã§çµæåãåã (yield a1) (yield a2) (while t (let ((next (+ a1 a2))) (setq a1 a2 a2 next) (yield next)))))) (funcall fib-gen) ; ä½åº¦ãå¼ãã§ã¿ã (funcall fib-gen) (funcall fib-gen) (funcall fib-gen) (funcall fib-gen) fib-list ; => (3 2 1 1 0)
Semaphoreã®ä¾ï¼cc:semaphore-acquire é¢æ°ã deferred ãè¿ãã®ã§ãããã«ç¶ãã¦å®è¡ããããã¿ã¹ã¯ãã¤ãªãã¦ããã¾ããæç³»åã§æåãå¤ãã£ã¦ããã®ã§ã³ã¼ãä¸ã«ç°¡åãªèª¬æãæ¸ãã¦ã¿ã¾ããã
;; permit=1ã®ã»ããã©ä½æ (setq smp (cc:semaphore-create 1)) ;; ç¶ãã¦3ã¤å®è¡ãããã¨ãã (deferred:nextc (cc:semaphore-acquire smp) (lambda(x) (message "go1"))) (deferred:nextc (cc:semaphore-acquire smp) (lambda(x) (message "go2"))) (deferred:nextc (cc:semaphore-acquire smp) (lambda(x) (message "go3"))) ;; => 1ã¤ç®ã ãå®è¡ãã㦠go1 ã表示ããã (cc:semaphore-release smp) ; permitãè¿ã ;; => 2ã¤ç®ãå®è¡ãã㦠go2 ã表示ããã (cc:semaphore-waiting-deferreds smp) ; go3 ã表示ããdeferred (cc:semaphore-release-all smp) ; => permitãåæåã㦠go3 ã表示ããdeferredãè¿ã (cc:semaphore-waiting-deferreds smp) ; => nil
Dataflowã®ä¾ï¼ cc:dataflow-environment é¢æ°ã§å¤æ°ãæ ¼ç´ãããç°å¢ããä½ãã¾ãã cc:dataflow-get ã¯å¤ã®åå¾ã¨ããã«ç¶ãã¿ã¹ã¯ãã¤ãªãã deferred ãè¿ãã¾ãã cc:dataflow-set ã§å¤ããã¤ã³ããã¾ããä¾ã§ã¯ãã¼ã«æååã使ã£ã¦ãã¾ããããã¼ã«ã¯ä»»æã®ãªãã¸ã§ã¯ããæå®ã§ãã¾ãã
(setq dfenv (cc:dataflow-environment)) ;; âåºæ¬ã®ä½¿ãæ¹ ;; âåæçã«å¤ãåå¾ããããã¯ããªãã (cc:dataflow-get-sync dfenv "abc") ; => nil ã¾ã å¤ãç¡ãã (deferred:$ ; abc ã¨ããå¤ãåã£ã¦ãã¦è¡¨ç¤ºããå¦ç (cc:dataflow-get dfenv "abc") (deferred:nextc it (lambda (x) (message "Got abc : %s" x)))) ;; => å¤ããªãã®ã§å¦çã¯ãããã¯ããã¾ã¾ (cc:dataflow-set dfenv "abc" 256) ; å¤ãã»ãã ;; => ããã§å ã»ã©ãããã¯ãã¦ããå¦çãåéãã "Got abc : 256" ã表示ããã (cc:dataflow-get-sync dfenv "abc") ; => 256 (cc:dataflow-clear dfenv "abc") ; å¤ãæªãã¤ã³ãã«æ»ã (cc:dataflow-get-sync dfenv "abc") ; => nil ;; âãªã¹ãããã¼ã«ãã (deferred:$ (cc:dataflow-get dfenv '("http://example.com/a.jpg" 300)) (deferred:nextc it (lambda (x) (message "a.jpg:300 OK %s" x)))) (cc:dataflow-set dfenv '("http://example.com/a.jpg" 300) 'jpeg) ;; => a.jpg:300 OK jpeg ;; â2ã¤ã®å¤ãå¾ ã¡åãã (deferred:$ ; abc, def ã®2ã¤ã®å¤ã使ã (deferred:parallel (cc:dataflow-get dfenv "abc") (cc:dataflow-get dfenv "def")) (deferred:nextc it (lambda (values) (apply 'message "Got values : %s, %s" values) (apply '+ values))) (deferred:nextc it (lambda (x) (insert (format ">> %s" x))))) ;; => ãã¡ãããããã¯ãã (cc:dataflow-get-waiting-keys dfenv) ; => ("def" "abc") (cc:dataflow-get-avalable-pairs dfenv) ; => ((("http://example.com/a.jpg" 300) . jpeg)) (cc:dataflow-set dfenv "abc" 128) ; ããã§ã¯ã¾ã ãããã¯ããã¾ã¾ (cc:dataflow-set dfenv "def" 256) ; ããã§ãã£ã¨åã ;; => Got values : 128, 256
Signalã®ä¾ï¼ cc:signal-channel ã§ã·ã°ãã«ãæµããã£ã³ãã«ãä½æãã¾ãããã®å¾ãsignalã«å¿çããå¦çãæ¥ç¶ãã¦ããã¾ãã
;; ã·ã°ãã«ã®ãã£ã³ãã«ãä½æ (setq channel (cc:signal-channel)) (cc:signal-connect ; foo ã¨ããã·ã°ãã«ãæ¾ã channel 'foo (lambda (event) (message "Signal : %S" event))) (cc:signal-connect channel t ; t ã«ããã¨ãã¹ã¦ã®ã·ã°ãã«ãæ¾ã (lambda (event) (destructuring-bind (event-name (args)) event (message "Listener : %S / %S" event-name args)))) (deferred:$ ; deferred ã§éåæã¿ã¹ã¯ãæ¥ç¶ã§ãã (cc:signal-connect channel 'foo) (deferred:nextc it (lambda (x) (message "Deferred Signal : %S" x)))) (cc:signal-send channel 'foo "hello signal!") ;; => ;; Listener : foo / "hello signal!" ;; Signal : (foo ("hello signal!")) ;; Deferred Signal : (foo ("hello signal!")) (cc:signal-send channel 'some "some signal!") ;; => ;; Listener : some / "some signal!"
dataflowã®å é¨ã«ã¯ãå¤æ°ã¸ã®ã¢ã¯ã»ã¹ããã¤ã³ãã®ã·ã°ãã«ãçºä¿¡ããchannelãããã¾ããããã使ã£ã¦ãæªãã¤ã³ãã®å¤æ°ã«å¤ãä½æãã¦ã»ãããããããªãã¨ãåºæ¥ã¾ãã
signalãdataflowã¯ãã«ã¹ã±ã¼ãæ¥ç¶ãã¦è¦ªåé¢ä¿ãæ§ç¯ã§ãã¾ããä¾ãã°ã親dataflowã«ããã©ã«ãå¤ï¼ãã©ã¼ã«ããã¯ã®å¤ï¼ãå ¥ãã¦ããã¨ããchannelã§è¦ªåé¢ä¿ãæ§ç¯ãã¦ãã¼ã«ã«ãªã¤ãã³ãã¨ã°ãã¼ãã«ãªã¤ãã³ããåãã¦å¹ççã«ã¤ãã³ãã管çãããªã©ãåºæ¥ã¾ãã
æ´»ç¨ä¾ç´¹ä»
åè¿°ã®éåæã§æ¬²ãããªããã®ã®ã²ã£ããè¿ãã«ãªãã¾ãããèªåã®ãã¼ã«(anything-books.el, cacoo.el, 3Dè¿·è·¯)ã§ä½¿ã£ã¦ããã¨ãããç°¡åã«ç´¹ä»ãã¾ããå¾ã§ãcacoo.el ã«ã¤ãã¦ã¯ããå°ã詳ãã解説ãããã¨æãã¾ãã
- éä¿¡ã»ããã»ã¹æ°å¶é
- semaphoreã§å®è¡æ°å¶å¾¡
- æä»å¶å¾¡ãå¦çã®ã·ãªã¢ã©ã¤ãº
- semaphore
- å®è¡æ°ï¼ã¨å²ãè¾¼ã¿ã使ã
- âããã¯semaphoreã«ããªãã¦ãããã£ããã
- ã¢ãã¡ã¼ã·ã§ã³
- threadã§åä½ä¸ã®ã¢ãã¡ã¼ã·ã§ã³ã表示
- å¦çæ¬ä½ããã® signal ã¤ãã³ããæ¾ã£ã¦ãã¹ã¬ããã®éå§ãåæ¢
- ã¦ã¤ã³ãã¦éã®éä¿¡
- signal/channel ã§è¡¨ç¤ºè¦æ±ãå¦çã¤ãã³ããéç¥
- ã¤ãã³ãåãåãå ã®ã¦ã¤ã³ãã¦ããããã¡ãããªãã¦ããã¾ããªã
- ããã»ã¹éã®éä¿¡
- éä¿¡ãããã³ã«ã signal/channel ã§ã©ãã
- ééçãªã¡ãã»ã¼ã¸ããã·ã³ã°éä¿¡ãå®ç¾
- ãã£ãã·ã¥ãä¾åé¢ä¿
- dataflow ã§ãã£ãã·ã¥ç®¡ç
- ãã£ãã·ã¥ãã¼ã¿éã®è¤éãªä¾åé¢ä¿ãã¤ãã³ãã管ç
- ä¾åé¢ä¿ã«ããåæã«å¦çããããã¯ããæºåãåºæ¥ããåéãã
- ãã£ãã·ã¥ãã¼ã¿è¦æ±ã® signal ãæ¾ã£ã¦ããã£ãã·ã¥ãã¹ãªããã¼ã¿ã®åå¾ãå å·¥ãéå§
cacoo.elã®ã¢ã¼ããã¯ãã£
cacoo.el ã¯æ¬æ ¼çã« concurrent.el ã使ã£ã¦ã¿ããã¼ã«ã§ãããããããªã¨ããã« concurrent.el ã®æ©è½ã使ã£ã¦ãã¾ããããã®ãã¡ã®éè¦ãªããã¤ãã«ã¤ãã¦è§£èª¬ãã¦ã¿ã¾ãã
cacoo.el èªä½ã«ã¤ãã¦ã¯以前の記事ãåç §ãã¦ãã ããã
å ¨ä½
ããã°ã©ã ã¯å¤§ããåãã¦2ã¤ã«åããã¾ããä¸ã¤ã¯ãããã¡ã®ä¸ã®ãã¼ã¯ã¢ãããç»åã§ç½®ãæããå¦çãããä¸ã¤ã¯ Cacoo API ã«æ¥ç¶ãã¦ãCacooã®çµµãAnythingã§é¸æãã¦è²¼ãä»ããå¦çã§ãã
åè ã®ãã¼ã¯ã¢ããã®ç»åãç½®ãæããå¦çã§ã¯ããwgetã§ç»ååå¾ããconvertã§ãµã¤ãºå¤æ´ããç»åããããã¡ã«è¡¨ç¤ºãã¨ããä¸é£ã®ã¿ã¹ã¯ãããã¾ããã¾ããããããã®ã¿ã¹ã¯ã®ææç©ã¯ãã£ãã·ã¥ã¨ãã¦ãã¼ã«ã«ã«ä¿åããã¾ãããããããã¾ã管çãããã¨ãä¸ã¤ã®ç®æ¨ã§ãã
å¾è ã®CacooAPIã«æ¥ç¶ããé¨åã§ã¯ãããã¯ã°ã©ã¦ã³ãã®ãããã¯ã¼ã¯å¦ç㯠deferred.el ã§è¡ãã¾ãããAnythingã®èµ·åãé 延ããããããã¬ãã¥ã¼ç»åã表示ããããããã¨ãã㧠concurrent.el ã使ã£ã¦ãã¾ãã
semaphoreã«ããããã»ã¹æ°å¶å¾¡
éä¿¡ãç»ååå¾ãImageMagickã«ãããªãµã¤ãºå¦çã¯ãå¤é¨ããã»ã¹ãèµ·åãã¦ãã¾ãããããã¯éåæã«å®è¡ããã¾ãããä½ãèããã«éåæã§æ¬¡ã ã«å®è¡ãããã¨ã大éã®å¤é¨ããã»ã¹ãåæã«èµ·åãã¦ãã¾ãã¾ããæ°åç¨åº¦ã§ããã°ããã»ã©åé¡ãªãã®ã§ãããä½ååãç»åãããå ´åã¯ãåæã«å¤§éã®HTTPã¢ã¯ã»ã¹ãçºçãã¦ãµã¼ãã¼ã«æå¦ããããããããã¯å¤§éã®ããã»ã¹ãèµ·åãã¦ã¡ã¢ãªä¸è¶³ã«ãªã£ã¦ãã¾ããªã©ã®ãã¦ã¼ã¶ã¼ã«ã¨ã£ã¦å¥½ã¾ãããªãç¶æ³ã«ãªãã¾ãã
é常ããã®ãããªåæå®è¡ããã¿ã¹ã¯ã®éãå¶éãããå ´åã«ã¯ã»ããã©ã使ãã¾ãã cacoo.el ã§ã¯ãè¨å®å¤æ°ã® cacoo:process-num ã§å¶éããããã»ã¹æ°ãæå®ããå®éã«ã¯ cacoo:process-semaphore ã«ã»ãããããã»ããã©ãªãã¸ã§ã¯ãã§åæå®è¡ã¿ã¹ã¯ã管çãã¾ããããã©ã«ãã¯4ã«ãªã£ã¦ãã¾ãã
cacoo:process-semaphore ã¯åå°ã®éåæã¿ã¹ã¯ã®ä¸ã§æ¨ªæçã«åºã¦ããã®ã§ãããå ¨ä½ãéãã¦èµ·åãããããã»ã¹æ°ãä¸éãè¶ ããªãããã«èª¿æ´ããã¾ãã
ãããä¸éãè¶ ããããã»ã¹ã®å®è¡ãè¦æ±ãããå ´åãã»ããã©ããã®å¦çããããã¯ãã¾ããããã¦å ã«å®è¡ããã¦ããå¦çãçµäºãã¦ä½è£ãåºã¦ãã段éã§ãå¾ ããã¦ãããã¿ã¹ã¯ãå®è¡ãã¾ãã
emacs-w3m ã«ãåæ§ã®å¦çãã¥ã¼ã®ãããªä»çµã¿ãããã¾ãããç¹å¥ã«éåæãæ±ãããã«ããªãè¤éãªã³ã¼ãã«ãªã£ã¦ãã¾ããéåæã¿ã¹ã¯ç¨ã»ããã©ã¯ä¸è¬çã«ãã¼ãºãé«ãã¨æ©è½ã§ã¯ãªããã¨æã£ã¦ãã¾ãã
thread ã«ããã¢ãã¡ã¼ã·ã§ã³ã¨ signal ã«ããå¦çç¶æ³ã®éç¥
æéã®ãããã¿ã¹ã¯ãå®è¡ãã¦ããã¨ããã¦ã¼ã¶ã¼ã«ä½ããã®é²è¡ç¶æ³ã®éç¥ãããã¹ãã§ããé常ã®GUIã¢ããªã§ããã°ãããã°ã¬ã¹ãã¼ã表示ãããã¢ãã¡ã¼ã·ã§ã³ã表示ãããã®ãå¤ãã§ãã
cacoo.el ã§ã¯ãAnythingã§ã®ãã¬ãã¥ã¼ç»å表示ã®ã¨ããã§ãããããåãã¢ãã¡ã¼ã·ã§ã³è¡¨ç¤ºã¨ãé²è¡ç¶æ³ã®éç¥ãè¡ã£ã¦ãã¾ãã
concurrent.el ã® thread ã使ããã¨ã§ã¢ãã¡ã¼ã·ã§ã³ã®æ´æ°ã»åæ¢å¦çãã·ã³ãã«ã«æ¸ããã¨ãåºæ¥ã¾ãããthread ãç¡ããã°èªåã§ã¿ã¤ãã¼ãé§ä½¿ããããã©ã°ã§æ¢ãããããªããã°ãªããããããããã¨ã®å²ã«ã¯è¤éãªã³ã¼ãã«ãªãã¾ãã
ã¾ããå¦çç¶æ³ã®éç¥ã«ã¤ãã¦ã¯ãã¡ã¤ã³ã®å¦çã§ãããåå¾âãªãµã¤ãºâ表示ãã®éåæã¿ã¹ã¯ãå¦çç¶æ³ã signal ã§ããã¼ããã£ã¹ããããããGUIå¨ãã®ã³ã³ãã¼ãã³ããé©å½ã«ã¤ãã³ããæ¾ã£ã¦ãã¦æ´æ°ããã¨ãããããªæ§æã«ãã¾ãããå®éã«ã¯ã¾ã æ´çãåãã¦ãªãã¨ãããããã®ã§ãããã¡ã¤ã³ã®éåæå¦çã¨GUIã®ã³ã¼ããããç¨åº¦åé¢ã§ããããã«æãã¾ãã
Dataflowã«ããç»åãã£ãã·ã¥ç®¡ç
ç»åã®ãã¼ã¯ã¢ããã表示ããããã«ã¯ãç»ååå¾ã¨ãªãµã¤ãºãè¡ãå¿ è¦ãããã¾ããæ¯åç»åãåãã«è¡ãã®ã¯ç¡é§ã§ãã®ã§ãåã£ã¦ãããªãªã¸ãã«ã®ç»åã¨ãªãµã¤ãºããç»åã¯ãã¼ã«ã«ã«ãã£ãã·ã¥ãã¦ããã¾ãããã®å¦çã®æµãã¨ãã£ãã·ã¥ãã¼ã¿ã®ä¾åé¢ä¿ã表ãã¨ä¸ã®å³ã®ããã«ãªãã¾ãã
ç¢å°ãä¾åæ¹åã§ãã®ã§ãå·¦å´ããã¼ã¿ã®ä¸æµã§ãã
æåããã¼ã¿ã®æµãã«å¾ã£ã¦å·¦å´ããé ã«éåæã¿ã¹ã¯ãå¦çãããããªããã°ã©ã ãæ¸ãã¦ãã¾ãããå³ã«æ¸ãã¨ãä¸å³ã®ããã§ãã
ãã£ãã·ã¥ã«ã¤ãã¦ã¯ããã£ãã·ã¥ããããã©ããã調ã¹ã¦ãããã°ã¿ã¹ã¯ãã¹ããããã¾ãã
ãã®æ¹æ³ã«ã¯åé¡ãããã¤ããããã¨ãåããã¾ãããã¾ããã¼ã¯ã¢ãããã¨ã«ç¬ç«ããã¿ã¹ã¯ã«ãªããããURLãåãç»åããã£ã¦ããç¡é§ã«ç»åãåãã«è¡ã£ã¦ãã¾ã£ããããã¼ã¿ãå¦çã競åãã¦æ£ããç»åã表示ã§ããªããªãã¾ãã
ã¾ãããç»åãåãã«è¡ã£ã¦ãªãµã¤ãºãã¦è¡¨ç¤ºããã¾ã§ããä¸ã¤ã®ã¢ãããã¯ãªåä½ã«ãªããããå¦çããã©ãã©ã«ãã¦éåæã¿ã¹ã¯ã®ã¹ã«ã¼ããããä¸ãããããªãã¨ãåºæ¥ã¾ããã
ããã§ããã¼ã¿ããã¼å¤æ°ã使ã£ã¦ä¾åé¢ä¿ããã®ã¾ã¾ããã°ã©ã ã«è½ã¨ããä¾åé¢ä¿ã®éã¯éåæã¡ãã»ã¼ã¸ã³ã°ã§æ¥ç¶ãããã¨ã«ãã¾ãããçµµã«æãã¨ä¸å³ã®ããã§ãã
ãã¼ã¿ããã¼å¤æ°ã使ã£ã¦ãä¾åå ã®ãã¼ã¿ãããã¤ããã®ããã°ã©ã ã«ãã
ããã«ãããã¢ãããã¯ãªéåæã¿ã¹ã¯ãä¾åé¢ä¿ã®ç¢å°1ã¤åã«åå²ãããå¹çããã¿ã¹ã¯ãå®è¡ãããã¨ãåºæ¥ãããã«ãªãã¾ãããããã«ããã¼ã¿ããã¼å¤æ°ã§å ¨ä½ã®ãã¼ã¿ãå ±æããããã«ãªã£ãããããã¼ã¯ã¢ããéã§åãURLããã£ãå ´åã¯ãåä¸ã®ç»åãã¼ã¿ã使ãããã«ãªãã¾ãããããã§ã競åãç¡é§ãªå¦çãèµ·ããªããªãã¾ããã
ã¾ããããã°ã©ã èªä½ãçããªããããã«åã¿ã¹ã¯ãç²çµåã«ãªã£ãããããããªãæ¡å¼µãããããããªãã¾ããã以åã®å®è£ ã§ã¯ãã©ã°ã¤ã³ã¯ããªãç¹å¥ãªã³ã¼ããæ¸ãã¦ãããããã£ãã·ã¥ããã¾ãåºæ¥ããå¹çãæªãã£ãã®ã§ãããä»åã®å®è£ ã§ã¯ãã¼ã¿ããã¼å¤æ°ã®æ çµã¿ã®ä¸ã§å¹çããå¦çã§ããããã«ãªãã¾ããã
ä¸æ¹ã§ããç»åãåãã«è¡ã£ã¦ãªãµã¤ãºãã¦è¡¨ç¤ºãããå ¨ä½ã®ã¿ã¹ã¯ããã©ãã©ã«ãªã£ããããã³ã¼ãããå ¨ä½ã®ã¿ã¹ã¯æµããèªã¿åããã¨ãé£ãããªãã¾ããããã®ãããªä¾åé¢ä¿ãã¤ãªãã¦ãã£ã¦å ¨ä½ãæ§ç¯ããã¢ã¼ããã¯ãã£ã§ã¯ãå ¨ä½ã俯ç°ããããã¥ã¡ã³ããéè¦ã«ãªãã¾ãã
Dataflowã«ããç»åãªã¹ã管ç
Cacooã®ãã¤ãã¼ã¢ã¼ããONã«ããã¨ãããã¯ã°ã©ã¦ã³ã㧠Cacoo API ããã·ã¼ãã®ä¸è¦§ãåå¾ãã¾ãããããä¸è¦§ã®åå¾éä¸ã§Anythingãèµ·åããå ´åãã¦ã¼ã¶ã¼ã«ãã°ããå¾ ã£ã¦ããã£ã¦ä¸è¦§åå¾å¾ã«Anythingãèµ·åããããã«ãã¾ãã
ä»åã®å®è£ ã§ã¯ãã¼ã¿ããã¼å¤æ°ã使ã£ã¦ãã·ã¼ãä¸è¦§ã®åå¾ã¨Anythingã®èµ·åã®å¾ ã¡åãããèªåçã«è¡ããããã«ãã¾ãããAnythingã¯ãã®å¤æ°ãåç §ããã³ã¼ããæ¸ãã ãã§ããã¼ã¿ãã¾ã ãã¤ã³ãï¼åå¾å®äºï¼ããã¦ããªããã°èªåçã«ãããã¯ããããã«ãªãã¾ããçµµã«æãã¨ä¸å³ã®ããã§ãã
éåæã®å¾ ã¡åããã¯ãã©ã°ãªã©ãå¤ç¨ãã¦åããã«ãããªããã¡ãªã®ã§ããããã®ãããªæ½è±¡çãªæ©è½ã使ããã¨ã§ã誰ããã¼ã¿ã®çç£è ã§èª°ãæ¶è²»è ãªã®ããã³ã¼ãã§ç¤ºããã¨ãåºæ¥ãããã«ãªãã¾ãã
ãã ãä½åº¦ãAnythingã³ãã³ããçºè¡ãããã¨ï¼ãããã¡ãªã±ã¼ã¹ï¼ããã¤ã³ãå¾ ã¡ã®ã¿ã¹ã¯ãæºã¾ã£ã¦ãã£ã¦ãã¾ãã®ã§ããã£ã±ããã©ã°ã使ã£ã¦ä¸ã¤ã ãã«ãªãããã«å¶éãã¦ãã¾ãã¾ãããå¤åãå·®åãªã¹ãã®ãããªãã¯ããã¯ã使ããã¨ã§ãããã¡ãã£ã¨ãã¾ãåºæ¥ããããªæ°ãããã®ã§ããããã¾ãé«åº¦ã«ãªãããã¦ãæå³ä¸æã«ãªãããã ã£ãã®ã§ããã®å®è£ ã¯ããã§è¯ãã£ãã¨æã£ã¦ãã¾ãã
ã¾ã¨ã
cacoo.el ã§ã¯ concurrent.el ã®å®åãã¹ãã¨ãããã¨ã§ãç©æ¥µçã«ãããããªã¨ããã«æ´»ç¨ãã¦ã¿ã¾ããã大åã¯ãã¾ãããã¾ããããã¾ã ã¾ã è¨è¨ãå®è£ ã«æ¹è¯ã®ä½å°ãããã¨ãããããã¾ããã
OOPã§ã¯ãéçãªå ¥ãç©ã¨ãã¦ã®ã¯ã©ã¹ãã¤ã³ã¹ã¿ã³ã¹ã¯ä¾¿å©ã ã£ãã®ã§ãããä¾åé¢ä¿ãå®è¡é åºãªã©ã®åçãªå´é¢ã®ç®¡çã¯ãã¾ã決å®æããªãã£ãæ°ããã¦ãã¾ãããä»åã®ä¸¦åããã°ã©ãã³ã°è¨èªé¢¨ã®æ©è½ã¯ããããã£ãåçãªå´é¢ããã¾ã管çã§ããããªæ触ãæã¡ã¾ããã
ã¨ãããã¨ã§ãä»å¾ã concurrent.el ãæ¹è¯ãã¦ããããã¨æãã¾ãã
ä»å¾ã®äºå®
ãªãã¨ãè±èªã§ãAPIããã¥ã¡ã³ãããããã¦ã deferred.el, concurrent.el ã宣ä¼ãã¦ã¿ããã¨æãã¾ãã
deferred.el ã ãã ã¨ããªããã£ãéããã足ããªãé¨åããã£ãããè¯ãããã¾ãä¼ãããªãããªã¨æã£ã¦ããã®ã§ãã¡ãã£ã¨èºèºãã¦ãã¾ããããã¨ãNode.jsã§ã·ã³ã°ã«ã¹ã¬ããã®éåæããã°ã©ãã³ã°ç°å¢ãåºã¾ã£ã¦ããã®ã§ããããããã®ã¨çµ¡ãã¦ãã·ã³ã°ã«ã¹ã¬ããã®Emacsã§ãååã«ãã³ã¤ã¤ãï¼ãã¨å®£ä¼ã§ããã¨è¯ãã®ããªã¨æã£ã¦ãã¾ããæ¨æºã§å ¥ãã¨ããã§ããã
å¾ã¯ã並åç³»ããã£ã¨ããã£ãã®ã§ãã£ã¨ skype.el ã®éåæåã¨æ©è½æ¹è¯ã«åãããããã¨æãã¾ãã
ãã®åã«ãcalfw.el ã®ãªãªã¼ã¹ã¨ããe2wm.elã®æ¹åã¨ããªãªã¼ã¹ã¨ããããããå±±çãããç¥ãã¾ããããã
- ãã®è¨äºã®å³ : https://cacoo.com/diagrams/jZmJVmA2XKQ3EPzX