Changeset e6e250d


Ignore:
Timestamp:
Mar 29, 2026, 11:03:25 PM (3 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Parents:
81ab5eb
Message:

3rd attempt at harmonizing isOp functions, e.g., isListed, isFirst, isLast

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/collections/list.hfa

    r81ab5eb re6e250d  
    1010// Created On       : Wed Apr 22 18:00:00 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Mar 29 21:20:44 2026
    13 // Update Count     : 101
     12// Last Modified On : Sun Mar 29 22:59:08 2026
     13// Update Count     : 104
    1414//
    1515
     
    188188
    189189static inline forall( tE &, tLinks & | embedded( tE, tLinks, dlink( tE ) ) ) {
    190         bool isListed( tE & node ) {
     190        bool listed( tE & node ) {
    191191          NOLOOSE(
    192192                verify( &node != 0p );
     
    195195          )
    196196          LOOSEONLY(
    197                 verify(false && "isListed is undefined");
     197                verify(false && "listed is undefined");
    198198                return true;
    199199          )
     
    204204                if ( ORIGIN_TAG_QUERY(( size_t)firstPtr) ) firstPtr = 0p;
    205205                return firstPtr == 0p;
    206         }
    207 
    208         bool isEmpty( dlist( tE, tLinks ) & list ) {            // deprecated
    209                 return empty( list );
    210206        }
    211207
     
    339335        }
    340336
    341         bool isFirst( tE & node ) {
     337        bool first( tE & node ) {
    342338                return recede( node );
    343339        }
    344340
    345         bool isLast( tE & node ) {
     341        bool last( tE & node ) {
    346342                return advance( node );
    347343    }
  • libcfa/src/collections/list2.hfa

    r81ab5eb re6e250d  
    1919// Created On       : Wed Apr 22 18:00:00 2020
    2020// Last Modified By : Peter A. Buhr
    21 // Last Modified On : Sun Mar 29 21:47:53 2026
    22 // Update Count     : 12
     21// Last Modified On : Sun Mar 29 22:59:31 2026
     22// Update Count     : 15
    2323//
    2424
     
    454454        }
    455455
    456         static inline bool isEmpty( dlist(tE, tLinks) & list ) __attribute__ ((deprecated));
    457         static inline bool isEmpty( dlist(tE, tLinks) & list ) {
    458                 return empty( list );
    459         }
    460 
    461         static inline bool isListed( tE & e ) {
     456        static inline bool listed( tE & e ) {
    462457          NOLOOSE(
    463458                verify (&e != 0p);
     
    469464          )
    470465          LOOSEONLY(
    471                 verify(false && "isListed is undefined");
     466                verify(false && "listed is undefined");
    472467                return true;
    473468          )
     
    516511        }
    517512
    518         bool isFirst( tE & node ) {
     513        bool first( tE & node ) {
    519514                // Probable bug copied from master
    520515                // should be `! recede(node)`
     
    524519        }
    525520
    526         bool isLast( tE & node ) {
     521        bool last( tE & node ) {
    527522                // ditto, vice versa
    528523                return advance( node );
  • libcfa/src/concurrency/channel.hfa

    r81ab5eb re6e250d  
    369369        ///////////////////////////////////////////////////////////////////////////////////////////
    370370        bool unregister_chan( channel(T) & chan, select_node & node ) with(chan) {
    371             if ( ! isListed( node ) && ! node.park_counter ) return false; // handle special OR case
     371            if ( ! listed( node ) && ! node.park_counter ) return false; // handle special OR case
    372372            lock( mutex_lock );
    373             if ( isListed( node ) ) { // op wasn't performed
     373            if ( listed( node ) ) { // op wasn't performed
    374374                remove( node );
    375375                unlock( mutex_lock );
  • libcfa/src/concurrency/future.hfa

    r81ab5eb re6e250d  
    1010// Created On       : Wed Jan 06 17:33:18 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Mar 29 21:13:04 2026
    13 // Update Count     : 223
     12// Last Modified On : Sun Mar 29 22:47:01 2026
     13// Update Count     : 224
    1414//
    1515
     
    7979
    8080                bool unregister_select$( future(T) & fut, select_node & s ) with( fut ) { // for waituntil statement
    81                   if ( ! isListed( s ) ) return false;
    82                         lock( lock );
    83                         if ( isListed( s ) ) remove( s );
     81                  if ( ! listed( s ) ) return false;
     82                        lock( lock );
     83                        if ( listed( s ) ) remove( s );
    8484                        unlock( lock );
    8585                        return false;
  • libcfa/src/concurrency/locks.cfa

    r81ab5eb re6e250d  
    220220bool unregister_select$( blocking_lock & this, select_node & node ) with(this) {
    221221        lock( lock __cfaabi_dbg_ctx2 );
    222         if ( isListed( node ) ) {
     222        if ( listed( node ) ) {
    223223                remove( node );
    224224                wait_count--;
     
    265265                //      may still be called after a thread has been removed from the queue but
    266266                //      before the alarm is unregistered
    267                 if ( isListed( *info_thd ) ) {                                  // is thread on queue
     267                if ( listed( *info_thd ) ) {                                    // is thread on queue
    268268                        info_thd->signalled = false;
    269269                        // remove this thread O(1)
     
    304304                //      may still be called after a thread has been removed from the queue but
    305305                //      before the alarm is unregistered
    306                 if ( isListed( *info_thd ) ) {                                  // is thread on queue
     306                if ( listed( *info_thd ) ) {                                    // is thread on queue
    307307                        info_thd->signalled = false;
    308308                        // remove this thread O(1)
  • libcfa/src/concurrency/locks.hfa

    r81ab5eb re6e250d  
    1111// Created On       : Thu Jan 21 19:46:50 2021
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Sun Nov 23 22:38:45 2025
    14 // Update Count     : 67
     13// Last Modified On : Sun Mar 29 22:46:39 2026
     14// Update Count     : 68
    1515//
    1616
     
    645645static inline bool unregister_select$( simple_owner_lock & this, select_node & node ) with( this ) {
    646646        lock( lock __cfaabi_dbg_ctx2 );
    647         if ( isListed( node ) ) {
     647        if ( listed( node ) ) {
    648648                remove( node );
    649649                unlock( lock );
  • tests/list/.expect/dlist-insert-remove.txt

    r81ab5eb re6e250d  
    11091109try_pop cases done
    11101110origin_mutation cases done
    1111 isListed cases done
     1111listed cases done
  • tests/list/dlist-insert-remove.cfa

    r81ab5eb re6e250d  
    14361436// Section 4g
    14371437//
    1438 // Test cases of empty, isFirst, isLast,
     1438// Test cases of empty, first, last,
    14391439// remove_first, remove_last, modifications via iter
    14401440//
     
    14691469        assert( &m3next == 0p );
    14701470
    1471         assert( ! isFirst( m1 ) );
    1472         assert( isLast( m1 ) );
    1473         assert( isFirst( m2 ) );
    1474         assert( isLast( m2 ) );
    1475         assert( isFirst( m3 ) );
    1476         assert( ! isLast( m3 ) );
     1471        assert( ! first( m1 ) );
     1472        assert( last( m1 ) );
     1473        assert( first( m2 ) );
     1474        assert( last( m2 ) );
     1475        assert( first( m3 ) );
     1476        assert( ! last( m3 ) );
    14771477
    14781478        printf("accessor_cases done\n");
     
    16151615}
    16161616
    1617 void test__isListed_cases__mary() {
    1618 
    1619         mary m1 = {1.7};        assert( ! isListed( m1 ) );
    1620         mary m2 = {2.7};        assert( ! isListed( m2 ) );
    1621         mary m3 = {3.7};        assert( ! isListed( m3 ) );
     1617void test__listed_cases__mary() {
     1618
     1619        mary m1 = {1.7};        assert( ! listed( m1 ) );
     1620        mary m2 = {2.7};        assert( ! listed( m2 ) );
     1621        mary m3 = {3.7};        assert( ! listed( m3 ) );
    16221622
    16231623        dlist(mary) ml;
    16241624
    1625         insert_last(ml, m1);    assert( isListed( m1 ) );  assert(! isListed( m2 ) );
    1626         insert_last(ml, m2);    assert( isListed( m2 ) );  assert(! isListed( m3 ) );
    1627         insert_last(ml, m3);    assert( isListed( m3 ) );
    1628 
    1629         remove( m1 );           assert( ! isListed( m1 ) );  assert(  isListed( m2 ) );
    1630         remove( m2 );           assert( ! isListed( m2 ) );  assert(  isListed( m3 ) );
    1631         remove( m3 );           assert( ! isListed( m3 ) );
    1632 
    1633         printf("isListed cases done\n");
     1625        insert_last(ml, m1);    assert( listed( m1 ) );  assert(! listed( m2 ) );
     1626        insert_last(ml, m2);    assert( listed( m2 ) );  assert(! listed( m3 ) );
     1627        insert_last(ml, m3);    assert( listed( m3 ) );
     1628
     1629        remove( m1 );           assert( ! listed( m1 ) );  assert(  listed( m2 ) );
     1630        remove( m2 );           assert( ! listed( m2 ) );  assert(  listed( m3 ) );
     1631        remove( m3 );           assert( ! listed( m3 ) );
     1632
     1633        printf("listed cases done\n");
    16341634}
    16351635
     
    19311931        test__try_pop__mary();
    19321932        test__origin_mutation__mary();
    1933         test__isListed_cases__mary();
     1933        test__listed_cases__mary();
    19341934
    19351935        return 0;
Note: See TracChangeset for help on using the changeset viewer.