guile-devel
[Top][All Lists]
Advanced

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

Re: scm_i_fraction_reduce thread safety


From: Marius Vollmer
Subject: Re: scm_i_fraction_reduce thread safety
Date: Wed, 21 Jan 2004 01:00:33 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> Marius Vollmer <address@hidden> writes:
>>
>> User code should only use scm_numerator and scm_denominator to access
>> parts of the fraction object and those functions will first reduce the
>> fraction (in a thread safe way).  Wouldn't that be enough?
>
> Yep, though it seems a shame the accessors have to be slowed down just
> so printing and equality can write back.

Is that slow down significant?  The logic could be like

  if fraction is not reduced:
    lock
    if fraction is not reduced:
      reduce it
    unlock
  read it

So in the common case of a reduced fraction, no locks would be
necessary.  (This works since a fraction can never go from reduced to
unreduced.)

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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