emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make-thread with lambda form instead of function symbol


From: Eric Abrahamsen
Subject: Re: make-thread with lambda form instead of function symbol
Date: Sun, 16 Apr 2017 18:12:17 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Eric Abrahamsen <address@hidden> writes:

> Okay, one more thread question...

Well, here's the long story: I'm messing with Gnus's nnir search
routines, trying to make a general search query language that can be
translated into backend-specific queries depending on which groups
you've selected to search. The idea is you could mark both an IMAP group
and an nnmaildir group (indexed by notmuch), enter a single search
query, the query would be transformed into backend-appropriate versions,
and you'd get one search group containing messages returned by backends.

So then I figured: if we're searching different backends at once, and
each backend does its heavy lifting in an external process, then threads
would allow those processes to do their work concurrently, and results
could come back faster.

(If I can get this to work, I hope to look at getting Gnus to fetch new
news concurrently, as well.)

But! My current implementation is causing Emacs to segfault. The actual
function looks like this:

(defun nnir-run-query (specs)
  (let* ((results [])
         (threads
          (mapcar
           (lambda (x)
             (let* ((server (car x))
                    (search-engine (nnir-server-to-search-engine server)))
               (make-thread
                (lambda ()
                  (setq results
                        (vconcat
                         (nnir-run-search
                          search-engine
                          server
                          (cdr (assq 'nnir-query-spec specs))
                          (cadr x))
                         results))))))
           (cdr (assq 'nnir-group-spec specs)))))
    (mapc #'thread-join threads)
    results))

I'm testing with a single IMAP server query (ie, only one thread is
being created). The nnir-run-search function for the IMAP backend ends
up calling nnimap-send-command--> nnimap-wait-for-response-->
nnheader-accept-process-output--> accept-process-output, so I'm
expecting that's where the thread yields.

I'm attaching the traceback here. Dunno if it's something I've done
wrong...

Thanks,
Eric

Attachment: log.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]