看板 Perl 關於我們 聯絡資訊
請教一下各位前輩 : 小弟最近在IPC上遇到了一些難題 , 或者說是在Win32環境下的IPC . 程式的需求是如此 : PROC_A 會呼叫 PROC_B , 之後PROC_A會在那裏等待PROC_B的訊息. 我目前是將雙方要溝通的訊息以檔案的方式解決 , 但是這似乎不是很理想 . 另外PROC_A在等待時 , 我是利用無窮迴圈不斷的去偵查檔案是否被改變 , 但這也似乎不理想. 雖然已經可以成功執行 , 但是我希望能利用一些技巧來加快效率 , 所以我自行分析一下需求 : 1. PROC_A 只需要等待 PROC_B send 的 Signal , 再去抓取資料 2. 雙方的資料希望是在一個share memory 當然我不會放過CPAN , Perl提供的IPC種類很多 , 但是很可惜 , 大多不support Win32. 唯一找到的Win32::MMF , 卻老是無法編譯成功 .我也嘗試過%SIG和kill搭配 , 但是效果和Unix似乎不一樣. 想請教各位先進 , 關於win32底下的IPC , 有甚麼建議嗎 ? 如果能推薦幾個模組給小弟參考, 更是感激不盡!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.37.102.246
herculus6502:我最近在看POE,號稱有現成的模組,不過學習曲線… 11/09 06:50
herculus6502:為了scalability一開始我都先用socket,本機再開檔案 11/09 06:52
herculus6502:以前用c的話是用namedpipe+waitforsingleobject 11/09 06:53
TONICOM:Share Memory 解決了,利用 Memory Mapped File Service. 11/09 14:02
TONICOM:剩下如何利用訊號來trigger行程 11/09 14:03
clkao:AnyEvent is your friend 11/09 17:24
TONICOM:感謝分享,我大蓋看了一下,確實符合需求,而且比我想像中還 11/10 13:30
TONICOM:多!!要來好好研究一下了 11/10 13:31
herculus6502:"You should avoid POE like the plague"..我笑了^_^ 11/10 15:48
herculus6502:不過我看了一下AnyEvent::Socket,感覺比POE簡單多了 11/10 16:01
herculus6502:有DELPHI的INDY的味道…不愧是clkao...Orz 11/10 16:03
TONICOM:關於Win32下的Signal , 我找到了一些資訊 : 11/11 11:33
TONICOM:On Windows, Perl basically does not support signals at 11/11 11:33
TONICOM: all, because Windows has no signals. 11/11 11:33
TONICOM:原因 : Signals are unsupported by the Win32 API. The C 11/11 11:34
TONICOM: Runtime provides crude support for signals, but there 11/11 11:35
TONICOM:are serious caveats, such as inability to die() or 11/11 11:36
TONICOM: exit() from a signal handler. Perl itself does not 11/11 11:36
TONICOM:guarantee that signal handlers will not interrupt 11/11 11:37
TONICOM:critical operations such as memory allocation, which 11/11 11:37
TONICOM: means signal invocation may throw perl internals into 11/11 11:38
TONICOM:disarray. For these reasons, signals are unsupported 11/11 11:39
TONICOM: at this time. 11/11 11:39
TONICOM:原因是擷取自ActivePerl網站 11/11 11:41