[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[STUMP] using threads in mode line modules to avoid blocking
From: |
Joseph Mingrone |
Subject: |
[STUMP] using threads in mode line modules to avoid blocking |
Date: |
Mon, 02 Mar 2015 13:44:54 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (berkeley-unix) |
Hi,
I've been playing around writing some mode line modules. I quickly
realized that anything that blocks, blocks the whole window manager.
Using threads improves the situation, but there are still hiccups.
These hiccups mean that hitting the prefix key results in a pause before
the rat shows up. This can be annoying because no one waits for the
rat before pressing the subsequent keys.
Below is some code that checks a remote maildir directory for new
messages. The hiccups occur when the connection to the remote host is
broken. Why this is? I hoped that threading would have meant a
smoother experience.
Joseph
(defun fmt-maildir-modeline (ml)
"Return the number of new mails"
(declare (ignore ml))
(let ((now (/ (get-internal-real-time) internal-time-units-per-second)))
(when (or (= 0 *maildir-prev-time*) (>= (- now *maildir-prev-time*) 60))
(setf *maildir-prev-time* now)
(sb-thread:make-thread
(lambda ()
(setf *new-mail-count*
(string-trim
'(#\Space #\Tab #\Newline)
(stumpwm::run-prog-collect-output
stumpwm::*shell-program* "-c"
(concatenate 'string "/usr/bin/ssh -p " *port*
" -x -o ConnectTimeout=1 " *user*
"@" *host* " 'ls " *path*
" | wc -l'"))))))))
(when (string= *new-mail-count* "0")
(setf *new-mail-count* ""))
(format nil "~a" *new-mail-count*))
- [STUMP] using threads in mode line modules to avoid blocking,
Joseph Mingrone <=