Changeset a7aea7d


Ignore:
Timestamp:
Jan 7, 2021, 1:17:47 PM (8 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
44e37ef
Parents:
2fc9664b
Message:

Fixed abandon function and futures and added test for it.

Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/locks.hfa

    r2fc9664b ra7aea7d  
    345345
    346346                // Mark the future as abandoned, meaning it will be deleted by the server
    347                 void abandon( future_t & this ) {
     347                bool abandon( future_t & this ) {
     348                        /* paranoid */ verify( this.ptr != 3p );
     349
     350                        // Mark the future as abandonned
    348351                        struct oneshot * got = __atomic_exchange_n( &this.ptr, 3p, __ATOMIC_SEQ_CST);
     352
     353                        // If the future isn't already fulfilled, let the server delete it
     354                        if( got == 0p ) return false;
    349355
    350356                        // got == 2p: the future is ready but the context hasn't fully been consumed
     
    352358                        if( got == 2p ) {
    353359                                while( this.ptr != 1p ) Pause();
    354                         }
    355 
     360                                got = 1p;
     361                        }
     362
     363                        // The future is completed delete it now
     364                        /* paranoid */ verify( this.ptr != 1p );
    356365                        free( &this );
    357                         return;
     366                        return true;
    358367                }
    359368
Note: See TracChangeset for help on using the changeset viewer.