Changeset c34bb1f for libcfa/src


Ignore:
Timestamp:
Aug 7, 2023, 3:08:14 PM (10 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
7c2820e
Parents:
27f2bef
Message:

fixed nonlocal exception edge case for program main and added poll() routine with no args that polls the currrent active coroutine

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/coroutine.cfa

    r27f2bef rc34bb1f  
    298298}
    299299
     300bool poll( coroutine$ * cor ) libcfa_public {
     301    nonlocal_exception * nl_ex = pop_ehm_head( cor );
     302
     303    // if no exceptions return false
     304    if ( nl_ex == 0p ) return false;
     305   
     306    // otherwise loop and throwResume all pending exceptions
     307    while ( nl_ex != 0p ){
     308        exception_t * ex = nl_ex->the_exception;
     309        free( nl_ex );
     310        throwResume *ex;
     311        nl_ex = pop_ehm_head( cor );
     312    }
     313   
     314    return true;
     315}
     316
     317bool poll() libcfa_public { return poll( active_coroutine() ); }
     318
    300319// user facing ehm operations
    301320forall(T & | is_coroutine(T)) {
     
    305324
    306325    // poll for non-local exceptions
    307     bool poll( T & cor ) libcfa_public {
    308         coroutine$ * base_cor = get_coroutine( cor );
    309         nonlocal_exception * nl_ex = pop_ehm_head( base_cor );
    310 
    311         // if no exceptions return false
    312         if ( nl_ex == 0p ) return false;
    313        
    314         // otherwise loop and throwResume all pending exceptions
    315         while ( nl_ex != 0p ){
    316             exception_t * ex = nl_ex->the_exception;
    317             free( nl_ex );
    318             throwResume *ex;
    319             nl_ex = pop_ehm_head( base_cor );
    320         }
    321        
    322         return true;
    323     }
     326    bool poll( T & cor ) libcfa_public { return poll( get_coroutine( cor ) ); }
    324327
    325328    // poll iff nonlocal ehm is enabled
  • libcfa/src/concurrency/coroutine.hfa

    r27f2bef rc34bb1f  
    219219
    220220// non local ehm and coroutine utility routines
     221bool poll( coroutine$ * cor );
     222bool poll();
     223
    221224forall(T & | is_coroutine(T)) {
    222225    void enable_ehm( T & cor );
  • libcfa/src/concurrency/kernel/startup.cfa

    r27f2bef rc34bb1f  
    487487        last = 0p;
    488488        cancellation = 0p;
     489    ehm_state.ehm_buffer{};
     490    ehm_state.buffer_lock{};
     491    ehm_state.ehm_enabled = false;
    489492}
    490493
Note: See TracChangeset for help on using the changeset viewer.