[Top][All Lists]

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

Re: Patch for fields of `struct buffer'

From: Tom Tromey
Subject: Re: Patch for fields of `struct buffer'
Date: Sun, 06 Feb 2011 19:34:51 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

>>>>> "Daniel" == Daniel Colascione <address@hidden> writes:

Tom> Instead of explicit locks, just let any symbol function as a lock, and
Tom> have the locks hidden in the C code.

Daniel> While elegant, I'm afraid using symbols as locks would lead to a
Daniel> proliferation of locks of code, not data. Using a symbol as a big global
Daniel> lock is easier than using gensym to get per-object locks.

I don't really understand this.  I think it doesn't matter, though,
since after thinking about it some more, I think that it at least makes
sense to want to lock buffers.

Tom> (Or an extension of this idea, let
Tom> any Lisp object be a lock -- "Java style".)

Daniel> This approach has potential. I believe JVMs get away with this trick at
Daniel> a cost of a machine word per object --- that's a big addition to a
Daniel> simple cons cell, of which Emacs has quite a few.

Modern JVMs don't pay anywhere near this price.  JVM developers noticed
a long time ago that most object's locks are never acquired, and that
those that are acquired are usually uncontended, and optimized their
implementations accordingly.

If we went the "lock anything" route, I would suggest a weak hash table
for locks, instead of putting the lock into the object.


reply via email to

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