• For what is this method good for ?

    From Bonita Montero@3:633/10 to All on Wed Jun 3 06:36:56 2026
    bool xshared_mutex::re_share()
    {
    uint64_t cmp = m_atomic.load( memory_order_relaxed ), niu;
    bool lastSharer;
    do
    {
    assert(check( cmp ));
    assert(cmp & SharersMask);
    if( !(cmp & WaitingExclusiveMask) )
    return false;
    if( (cmp & WaitingSharersMask) == WaitingSharersMask )
    throw overflow();
    niu = cmp - SharerValue + WaitingSharersValue;
    uint64_t niuLast = (niu - WaitingExclusiveValue) | ExclusiveFlag;
    lastSharer = !(niu & SharersMask);
    niu = lastSharer ? niuLast : niu;
    } while( !m_atomic.compare_exchange_strong( cmp, niu, memory_order_release, memory_order_relaxed ) );
    if( lastSharer )
    releaseExclusive();
    waitShared();
    return true;
    }

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Jun 3 14:50:45 2026
    On 6/2/2026 9:36 PM, Bonita Montero wrote:
    bool xshared_mutex::re_share()
    {
    ˙˙˙˙uint64_t cmp = m_atomic.load( memory_order_relaxed ), niu;
    ˙˙˙˙bool lastSharer;
    ˙˙˙˙do
    ˙˙˙˙{
    ˙˙˙˙˙˙˙ assert(check( cmp ));
    ˙˙˙˙˙˙˙ assert(cmp & SharersMask);
    ˙˙˙˙˙˙˙ if( !(cmp & WaitingExclusiveMask) )
    ˙˙˙˙˙˙˙˙˙˙˙ return false;
    ˙˙˙˙˙˙˙ if( (cmp & WaitingSharersMask) == WaitingSharersMask )
    ˙˙˙˙˙˙˙˙˙˙˙ throw overflow();
    ˙˙˙˙˙˙˙ niu = cmp - SharerValue + WaitingSharersValue;
    ˙˙˙˙˙˙˙ uint64_t niuLast = (niu - WaitingExclusiveValue) | ExclusiveFlag;
    ˙˙˙˙˙˙˙ lastSharer = !(niu & SharersMask);
    ˙˙˙˙˙˙˙ niu = lastSharer ? niuLast : niu;
    ˙˙˙˙} while( !m_atomic.compare_exchange_strong( cmp, niu, memory_order_release, memory_order_relaxed ) );
    ˙˙˙˙if( lastSharer )
    ˙˙˙˙˙˙˙ releaseExclusive();
    ˙˙˙˙waitShared();
    ˙˙˙˙return true;
    }

    You are going to me more explicit, and clarify. Perhaps an atomic hand
    off? Not sure.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Jun 4 06:22:00 2026
    Am 03.06.2026 um 23:50 schrieb Chris M. Thomasson:
    On 6/2/2026 9:36 PM, Bonita Montero wrote:
    bool xshared_mutex::re_share()
    {
    ˙˙˙˙˙uint64_t cmp = m_atomic.load( memory_order_relaxed ), niu;
    ˙˙˙˙˙bool lastSharer;
    ˙˙˙˙˙do
    ˙˙˙˙˙{
    ˙˙˙˙˙˙˙˙ assert(check( cmp ));
    ˙˙˙˙˙˙˙˙ assert(cmp & SharersMask);
    ˙˙˙˙˙˙˙˙ if( !(cmp & WaitingExclusiveMask) )
    ˙˙˙˙˙˙˙˙˙˙˙˙ return false;
    ˙˙˙˙˙˙˙˙ if( (cmp & WaitingSharersMask) == WaitingSharersMask )
    ˙˙˙˙˙˙˙˙˙˙˙˙ throw overflow();
    ˙˙˙˙˙˙˙˙ niu = cmp - SharerValue + WaitingSharersValue;
    ˙˙˙˙˙˙˙˙ uint64_t niuLast = (niu - WaitingExclusiveValue) |
    ExclusiveFlag;
    ˙˙˙˙˙˙˙˙ lastSharer = !(niu & SharersMask);
    ˙˙˙˙˙˙˙˙ niu = lastSharer ? niuLast : niu;
    ˙˙˙˙˙} while( !m_atomic.compare_exchange_strong( cmp, niu,
    memory_order_release, memory_order_relaxed ) );
    ˙˙˙˙˙if( lastSharer )
    ˙˙˙˙˙˙˙˙ releaseExclusive();
    ˙˙˙˙˙waitShared();
    ˙˙˙˙˙return true;
    }

    You are going to me more explicit, and clarify. Perhaps an atomic hand
    off? Not sure.

    The reader's writer lock I wrote has a 64 bit word with three 21
    bit counters. The lowest 21 bit count the number of currently active
    sharers. The next 21 bit are the numbers of threads which are apply-
    ing to share the lock. The next 21 bit are the number of threads
    which apply for an exlusive ownership. Bit 63 is a bit that there's
    a thread which owns the lock in exclusive mode.
    Usually the lock is write preferring (controlled via a bit), i.e. if
    there are a number of threads which are currently sharing and a threads
    applies for exclusive mode the last mentioned counter is incremented
    and all further threads which want to share are delayed and the counter
    of threads which apply for sharing is incremented.
    If mutiple threads are constantly locking and unlocking the lock in
    shared mode to allow writers to proceed this may result in a lot of
    cachline traffic. The above function allows a thread to remain in
    shared mode and poll if there are threads which want to apply for
    exlusive mode. If there were no such threads the cacheline holding
    the mentioned counters and flags is usually remained in shared mode,
    i.e. there's usually no additional cacheline traffic.
    If there are threads which are waiting for exclusive mode the thread
    executing the above code switches from sharer mode to waitinf for
    shared access mode. If it is the last sharer that does this a thread
    waiting for exclusive mode is awakened.



    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From ??Jacek Marcin Jaworski??@3:633/10 to All on Fri Jun 5 04:03:01 2026
    W dniu 3.06.2026 o˙06:36, Bonita Montero pisze:
    bool xshared_mutex::re_share()
    {
    [cut - pure rubbish]
    }

    Why do you expect that Usenet readers are like modern C++ compilers?
    So, if you have any problem with algorithms please describe them in one
    common way:
    1. Poem;
    2. List of steps;
    3. Graph of step blocks;
    4. Decision tree.

    Major computing problems are:
    1. Algorithms;
    2. Architecture;
    3. Coding style.

    In that way. Fancy C++ dialect is last of main computing problems. And
    more: Your coding style is encapsulated in your projects. And anybody
    outside will not care.

    --
    Z totaliztycznym salutem!
    Jacek Marcin Jaworski, Pruszcz Gd., woj. Pomorskie, Polska ??, UE ??;
    tel.: +48-609-170-742, najlepiej w godz.: 5:00-5:55 lub 16:00-17:25; <jmj@energokod.gda.pl>, gpg: 4A541AA7A6E872318B85D7F6A651CC39244B0BFA;
    Domowa s. WWW: <https://energokod.gda.pl>;
    Mini Netykieta: <https://energokod.gda.pl/MiniNetykieta.html>;
    Mailowa Samoobrona: <https://emailselfdefense.fsf.org/pl>.
    UWAGA:
    NIE ZACI?GAJ "UKRYTEGO D?UGU"! P?A? ZA PROG. FOSS I INFO. INTERNETOWE!
    CZYTAJ DARMOWY: "17. Raport Totaliztyczny - Patroni Kontra Bankierzy": <https://energokod.gda.pl/raporty-totaliztyczne/17.%20Patroni%20Kontra%20Bankierzy.pdf>


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From ??Jacek Marcin Jaworski??@3:633/10 to All on Fri Jun 5 04:28:05 2026
    W dniu 5.06.2026 o˙04:03, ??Jacek Marcin Jaworski?? pisze:
    W dniu 3.06.2026 o˙06:36, Bonita Montero pisze:
    bool xshared_mutex::re_share()
    {
    [cut - pure rubbish]
    }

    Why do you expect that Usenet readers are like modern C++ compilers?

    And no, it is not hate, nor personal attack, but just "buddy to buddy reprimand". ChatGPT says:

    **Buddy-to-buddy reprimand** is an informal correction, warning, or expression of disapproval given by one peer, friend, or colleague to another, rather than by a person in a position of authority.

    **Definition:**

    A *buddy-to-buddy reprimand* is a friendly but direct criticism or warning delivered between equals, intended to correct behavior, point out a mistake, or encourage better judgment without invoking formal authority or disciplinary procedures.

    **Example:**

    "Instead of reporting him to the manager, she gave him a buddy-to-buddy reprimand and asked him not to do it again."

    The phrase emphasizes that the reprimand comes from a relationship of camaraderie or equality ("buddy") rather than from a boss, teacher, parent, or other authority figure.

    --
    Z totaliztycznym salutem!
    Jacek Marcin Jaworski, Pruszcz Gd., woj. Pomorskie, Polska ??, UE ??;
    tel.: +48-609-170-742, najlepiej w godz.: 5:00-5:55 lub 16:00-17:25; <jmj@energokod.gda.pl>, gpg: 4A541AA7A6E872318B85D7F6A651CC39244B0BFA;
    Domowa s. WWW: <https://energokod.gda.pl>;
    Mini Netykieta: <https://energokod.gda.pl/MiniNetykieta.html>;
    Mailowa Samoobrona: <https://emailselfdefense.fsf.org/pl>.
    UWAGA:
    NIE ZACI?GAJ "UKRYTEGO D?UGU"! P?A? ZA PROG. FOSS I INFO. INTERNETOWE!
    CZYTAJ DARMOWY: "17. Raport Totaliztyczny - Patroni Kontra Bankierzy": <https://energokod.gda.pl/raporty-totaliztyczne/17.%20Patroni%20Kontra%20Bankierzy.pdf>


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Fri Jun 5 05:55:02 2026
    Am 05.06.2026 um 04:03 schrieb ??Jacek Marcin Jaworski??:
    W dniu 3.06.2026 o˙06:36, Bonita Montero pisze:
    bool xshared_mutex::re_share()
    {
    [cut - pure rubbish]
    }

    Why do you expect that Usenet readers are like modern C++ compilers?
    So, if you have any problem with algorithms please describe them in one common way:
    1. Poem;
    2. List of steps;
    3. Graph of step blocks;
    4. Decision tree.

    Major computing problems are:
    1. Algorithms;
    2. Architecture;
    3. Coding style.

    In that way. Fancy C++ dialect is last of main computing problems. And
    more: Your coding style is encapsulated in your projects. And anybody outside will not care.

    If you need help handle the code to an AI.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)