Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
2472a19
Parents:
f6f0cca3 (diff), c7d8100c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutine

    rf6f0cca3 rff29f08  
    3232//-----------------------------------------------------------------------------
    3333// Ctors and dtors
    34 void ?{}(coStack_t & this);
    35 void ?{}(coroutine_desc & this);
    36 void ?{}(coroutine_desc & this, const char * name);
    37 void ^?{}(coStack_t & this);
    38 void ^?{}(coroutine_desc & this);
     34// void ?{}( coStack_t & this );
     35// void ^?{}( coStack_t & this );
     36
     37void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize );
     38void ^?{}( coroutine_desc & this );
     39
     40static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", NULL, 0 }; }
     41static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", NULL, stackSize }; }
     42static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
     43static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, NULL, 0 }; }
     44static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; }
    3945
    4046//-----------------------------------------------------------------------------
     
    6672// Suspend implementation inlined for performance
    6773static inline void suspend() {
    68         coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
     74        // optimization : read TLS once and reuse it
     75        // Safety note: this is preemption safe since if
     76        // preemption occurs after this line, the pointer
     77        // will also migrate which means this value will
     78        // stay in syn with the TLS
     79        coroutine_desc * src = TL_GET( this_coroutine );
    6980
    7081        assertf( src->last != 0,
     
    8394forall(dtype T | is_coroutine(T))
    8495static inline void resume(T & cor) {
    85         coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
     96        // optimization : read TLS once and reuse it
     97        // Safety note: this is preemption safe since if
     98        // preemption occurs after this line, the pointer
     99        // will also migrate which means this value will
     100        // stay in syn with the TLS
     101        coroutine_desc * src = TL_GET( this_coroutine );
    86102        coroutine_desc * dst = get_coroutine(cor);
    87103
     
    101117                dst->last = src;
    102118                dst->starter = dst->starter ? dst->starter : src;
    103         } // if
     119        }
    104120
    105121        // always done for performance testing
     
    108124
    109125static inline void resume(coroutine_desc * dst) {
    110         coroutine_desc * src = TL_GET( this_coroutine );                        // optimization
     126        // optimization : read TLS once and reuse it
     127        // Safety note: this is preemption safe since if
     128        // preemption occurs after this line, the pointer
     129        // will also migrate which means this value will
     130        // stay in syn with the TLS
     131        coroutine_desc * src = TL_GET( this_coroutine );
    111132
    112133        // not resuming self ?
     
    119140                // set last resumer
    120141                dst->last = src;
    121         } // if
     142        }
    122143
    123144        // always done for performance testing
Note: See TracChangeset for help on using the changeset viewer.