è¯ãããã°ã©ããç®æããªããConcurrent Progrmming in MLãã¯ä»ããèªãã¹ã
ï¼ãããã©ããåããåºãããã¨ã¯æã£ã¦ãã®ã§ãã¡ãã£ã¨ä¾¿ä¹ãï¼
ãããããã«ãã³ã¢å½ãåæ代ã«ãªãã並è¡å¦çãæ±ããããã«ãªããããã§ã並è¡å¦çã£ã¦é£ãéããããããªè«¸æ°ã«æå ±ã§ããç°¡åãã¤å®å
¨ã«ãã«ãã¹ã¬ãããæ±ããæ¹æ³ãããã¾ãã
ããã¯ãã¡ãã»ã¼ã¸ããã·ã³ã°ã«ããã¹ã¬ããéæ
å ±å
±æã§ããErlangã®ãããªã¢ã¯ã¿ã¼ã¢ãã«ã¨è¨ã£ãæ¹ããã³ã¨ãã人ãããããããã¾ãããã¡ãã»ã¼ã¸ããã·ã³ã°ã®ä¸çã«ã¯ããã¯ãã·ã°ãã«ãç»å ´ãã¾ãããããã®ã¯ãã¹ã¬ããéã§å
±æããéä¿¡è·¯ã ãã§ãããªãéä¿¡è·¯ã ãã§ãæä»å¶å¾¡ãåºæ¥ãã®ã§ããããï¼æ°ããã¹ã¬ãããä½ã£ã¦ããã®ã¹ã¬ãããæã¤æååãèªã¿æ¸ãããã¡ãã»ã¼ã¸ããã·ã³ã°ã¹ã¿ã¤ã«ã®ããã°ã©ã ãè¦ãã°ä¸ç®çç¶ã§ãã
(* ç´°ããäºã¯è¥å¹²åç´åãããµã³ãã«ããã°ã©ã ã§ãã*) let start_server init_msg = let ch = (* éä¿¡è·¯ãä½ã *) new_channel () in let rec loop msg = (* æ°ããä½ãããã¹ã¬ããã®ã«ã¼ã *) match receive ch with `Read reply -> send reply msg; loop msg | `Write new_msg -> loop new_msg in ignore (Thread.create loop init_msg); (* ã¹ã¬ããèµ·å *) ch (* èªã¿è¾¼ã¿ *) let read ch = let reply = new_channel () in send ch (`Read reply); receive reply (* æ¸ã込㿠*) let write ch msg = send ch (`Write msg)
ãã®ããã°ã©ã ã¯ãæååãå
å
ããã¹ã¬ãããä¸ã¤ä½ããéä¿¡è·¯(ch)çµç±ã§èªã¿è¾¼ã¿æ¸ãè¾¼ã¿å½ä»¤ããã度ã«èªèº«ã®æååãè¿ããããæ´æ°ããããã¦ãã¾ããè¦ããã«ãã¹ã¬ããã¯ã«ã¼ãããªããåä¸ã®è¦æ±ã«å¿ããã®ã§ãä¸åå
é¨å¤æ°ã®ããã¯ããããå¿
è¦ããªãã®ã§ããæååãç ´å£çã«ä»£å
¥ãã¦ããªãã¨ããã®ããã¤ã³ãã§ãã
ï¼åæã ã¨ãéåæã ã¨ããã話ã横ã«ç½®ãã°ï¼åçã¯ããã ãã§ãããã£ãããã ãã®äºã§ãä¸è¦æå³ä¸æãªmutexã®æ±ããã解æ¾ããããã«ãã¹ã¬ããããã°ã©ã ãåçã«ç°¡åã«ãªãã¾ããæ¢ã«Erlangã¯ãããå®è¨¼ãã¦ããã¨ãè¨ããã§ãããã
ããããErlangã使ããªãããããªãã®ãã£ã¦ï¼ãããããä¸ã®ããã°ã©ã ã¯OCamlã®ããã°ã©ã ã§ããOCamlã§ã¯ã¡ãã»ã¼ã¸ããã·ã³ã°ã®ä»çµã¿ãEventã¢ã¸ã¥ã¼ã«ã¨å¼ã°ãã270è¡ç¨ã®ããã°ã©ã ã§å®ç¾ãã¦ãã¾ããScalaã«ã¯Scala Actorãããã¾ãããJavaã«ã¯Kilim(http://www.malhar.net/sriram/kilim/)ã¨ããã©ã¤ãã©ãªãããã¾ããã¡ãã»ã¼ã¸ããã·ã³ã°ã¯è¨èªã§å®è£
ããªããã°ãªããªããã®ã§ã¯ãªããããã©ã¤ãã©ãªã¨ãã¦èº«è¿ã«ããã®ã§ãã
ã§ã¯ããã®ã¡ãã»ã¼ã¸ããã·ã³ã°ã«ãããã«ãã¹ã¬ããããã°ã©ãã³ã°ãå
·ä½çã«ã¯ã©ãæ¸ãã°ããã®ãï¼ãã®è©±ã詳ããè¼ã£ã¦ããã®ããConcurrent Programming in MLãã§ãã
http://www.amazon.com/Concurrent-Programming-ML-John-Reppy/dp/0521480892
ãã²ã¡ãã»ã¼ã¸ããã·ã³ã°ã®ä¸çã®æãéãã¦ã¿ã¦ãã ããã