Changeset ff29f08 for src/libcfa/concurrency/coroutine
- Timestamp:
- May 18, 2018, 2:09:21 PM (7 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutine
rf6f0cca3 rff29f08 32 32 //----------------------------------------------------------------------------- 33 33 // 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 37 void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ); 38 void ^?{}( coroutine_desc & this ); 39 40 static inline void ?{}( coroutine_desc & this) { this{ "Anonymous Coroutine", NULL, 0 }; } 41 static inline void ?{}( coroutine_desc & this, size_t stackSize) { this{ "Anonymous Coroutine", NULL, stackSize }; } 42 static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize ) { this{ "Anonymous Coroutine", storage, storageSize }; } 43 static inline void ?{}( coroutine_desc & this, const char * name) { this{ name, NULL, 0 }; } 44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; } 39 45 40 46 //----------------------------------------------------------------------------- … … 66 72 // Suspend implementation inlined for performance 67 73 static 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 ); 69 80 70 81 assertf( src->last != 0, … … 83 94 forall(dtype T | is_coroutine(T)) 84 95 static 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 ); 86 102 coroutine_desc * dst = get_coroutine(cor); 87 103 … … 101 117 dst->last = src; 102 118 dst->starter = dst->starter ? dst->starter : src; 103 } // if119 } 104 120 105 121 // always done for performance testing … … 108 124 109 125 static 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 ); 111 132 112 133 // not resuming self ? … … 119 140 // set last resumer 120 141 dst->last = src; 121 } // if142 } 122 143 123 144 // always done for performance testing
Note:
See TracChangeset
for help on using the changeset viewer.