[Top][All Lists]

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

Re: Concurrency via isolated process/thread

From: Ihor Radchenko
Subject: Re: Concurrency via isolated process/thread
Date: Mon, 24 Jul 2023 14:24:32 +0000

Eli Zaretskii <eliz@gnu.org> writes:

> So the goal is to eventually support true concurrency in Emacs?


> ... so these steps only make sense if the
> concurrency is attainable via these measures?

Yes, except that the part about thread-local point and restriction may
be more generally useful.

>> Consider a simple regexp search running in a thread:
>> (while (re-search-forward re nil t)
>>   (do-useful-staff)
>>   (thread-yield))
>> This search will fail if another thread ever moves point or changes
>> restriction in the same buffer.
> You are considering just the simplest scenario.  Usually, Lisp
> programs in Emacs not only read text, they also write and delete it.
> What if one thread makes changes to buffer text and another thread
> then wants to access it using its state variables?  E.g., what do you
> plan doing about the gap? will thread switch move the gap or
> something? that alone is a performance killer.

AFAIK, reading buffer does not require moving the gap.

We only need to move the gap when buffer is changed or before copying
text region from buffer to another buffer. Both such operations should
be considered buffer modifications and must be blocking.

> To be a step in the general direction of achieving concurrency, we
> need some plan that will at least in principle allow concurrent
> editing.  Even if "concurrent" here means that only one thread can
> write to a buffer at a time, we still need to see how this will work
> when other threads are unblocked once the writer thread is done
> writing.  Can you describe how this will work, assuming we keep the
> current design of buffer with a gap?

The idea is the same as with what is already done for indirect buffers.
Indirect buffer modification will affect buffer_text object in the
base buffer (automatically - buffer_text object is shared). And they
will also affect point position in the base buffer.

The point adjustment in the base buffer is done simply by storing point
as a marker. We can do the same for thread-local point positions.

Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

reply via email to

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