ドキュメントには、with-timeout
マクロが内部で実行するコードが「待機できるプリミティブである」場合にのみ待機できると記載されています。そのようなプリミティブの例はありますか?
詳細情報: TCP サーバーへの非同期呼び出しを行う関数から結果を返さなければならない状況があります。したがって、この呼び出しを同期させる方法を知っていれば、それも役に立ちます。
残念ながら、同期的に行うことはできません。これはオートコンプリート ライブラリによって呼び出されるコールバックであり、値を返す必要があります。以下は、それを実行しようとするコードです。
(defun haxe-ac-init ()
(unless (get-process haxe-compiler-process)
(haxe-connector-sentinel nil nil))
(let ((ac-request
(haxe-build-compile-string
(haxe-package) (buffer-file-name))))
(save-buffer)
(setq haxe-last-ac-candidates nil)
(process-send-string haxe-compiler-process ac-request)
(process-send-string haxe-compiler-process "\0")
(process-send-eof haxe-compiler-process))
(haxe-log 3 "haxe-ac-init sent request.")
(with-local-quit
(with-timeout (3 (haxe-log 0 "Compiler is too slow..."))
(block x ;; this while sometimes will loop forever
(while (equal (process-status (get-process haxe-compiler-process)) 'open)
(when (and last-compiler-response (= received-status 2))
(haxe-parse-ac-response last-compiler-response)
(throw 'x haxe-last-ac-candidates)))))))