all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: phst@google.com, emacs-devel@gnu.org
Subject: Re: [PATCH] Support threads in modules
Date: Sat, 22 Apr 2017 23:14:18 +0300	[thread overview]
Message-ID: <83r30kp5d1.fsf@gnu.org> (raw)
In-Reply-To: <CAArVCkRYxvPw_GUdpgdkW4W38=dRXv-BRsdGyw=jr17yOQV4rw@mail.gmail.com> (message from Philipp Stephani on Sat, 22 Apr 2017 20:05:19 +0000)

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 22 Apr 2017 20:05:19 +0000
> Cc: emacs-devel@gnu.org, phst@google.com
> 
>  I agree that checking for the main thread is not TRT, but why not
>  allow any thread of those in all_threads? Why do we care that the env
>  pointer was created by the same thread as the one using it? We should
>  only care that the invoking thread is one of the Emacs application
>  threads, no?
> 
> - Using objects across threads requires careful synchronization.

Not sure what synchronization you have in mind.  There's only one
running thread at any given time, and a thread cannot be preempted
while it runs Lisp, so synchronization seems unnecessary, as a thread
cannot modify a Lisp object that another thread is modifying.

> - The more restrictive the module API is, the more freedom we have in the implementation.

I don't think I understand this.  From my POV, restricting modules to
be called only from one thread is too restrictive, and I see no reason
for that.

> - The current check is easy to implement and understand. A check for multiple threads would require another
> hash table with thread IDs etc.

Why do you need a has table?  There's a linked list in all_threads
which holds all the known application threads, we just need a loop
over them.

> - The Emacs module API is modelled after JNI, which has the same restriction
> (http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html).

Themodule API is modelled after JNI, but the threads model is a far
cry from Java threads.  So I don't think this argument is relevant,
unless you can show specific problems with our implementation of
threads.

Modules were added to Emacs to allow easy interfaces to external
libraries.  It makes very little sense to me to arbitrarily restrict
the use of such external libraries in only some threads.  IMO, it's a
grave limitation.



  reply	other threads:[~2017-04-22 20:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-22 15:24 [PATCH] Support threads in modules Philipp Stephani
2017-04-22 19:09 ` Eli Zaretskii
2017-04-22 19:21   ` Philipp Stephani
2017-04-22 19:49     ` Eli Zaretskii
2017-04-22 20:05       ` Philipp Stephani
2017-04-22 20:14         ` Eli Zaretskii [this message]
2017-04-23  6:14           ` John Wiegley
2017-04-23 12:40             ` Stefan Monnier
2017-04-26  5:23               ` Eli Zaretskii
2017-04-23 15:54             ` Philipp Stephani
2017-04-23 15:52           ` Philipp Stephani
2017-04-26  5:31             ` Eli Zaretskii
2017-06-10 11:38               ` Philipp Stephani
2017-06-10 12:38                 ` Eli Zaretskii
2017-06-10 19:58                   ` Philipp Stephani
2017-06-11 13:25                     ` Philipp Stephani
2017-06-11 14:54                       ` Eli Zaretskii
2017-06-11 17:12                         ` Philipp Stephani
2017-06-11 15:01                     ` Eli Zaretskii
2017-06-12 15:04                       ` Philipp Stephani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r30kp5d1.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=phst@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.