Re: [閒聊] ignore_user_abort()
※ 引述《buganini (霸格尼尼)》之銘言:
: 然後這個php沒執行完就被中斷了
: 所以弄出jpg檔的動作沒做到
: 後來用以下兩行解決
: ignore_user_abort(true);
: set_time_limit(0);
: ignore_user_abort()可以讓php不會被中斷
: 於是一系列動作都會乖乖的執行完
剛突然想到,這是不是可以用來模擬 threading ?
假設寫了一個 thread.php 然後分別執行 n 次,
那麼應該就會有 n 個 thread.php 在執行...
(所以實際上應該是 multi-process programming :P)
<?php //thread.php
ignore_user_abort(true);
set_time_limit(0);
while(1) { // 無限迴圈
// do something ...
}
?>
sync 的部分可以用資料庫讀寫同一個欄位、或是讀寫同一個檔案,
但是 sleep() / wakeup() 之類的功能該怎麼達成勒?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.119.199.121
※ 編輯: foxzgerald 來自: 140.119.199.121 (05/19 10:57)
推
05/19 19:16, , 1F
05/19 19:16, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章