- File:
-
- 1 edited
-
src/libcfa/concurrency/coroutine (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutine
r14a61b5 rb10affd 32 32 //----------------------------------------------------------------------------- 33 33 // Ctors and dtors 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 }; } 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); 45 39 46 40 //----------------------------------------------------------------------------- … … 72 66 // Suspend implementation inlined for performance 73 67 static inline void suspend() { 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 ); 68 coroutine_desc * src = TL_GET( this_coroutine ); // optimization 80 69 81 70 assertf( src->last != 0, … … 94 83 forall(dtype T | is_coroutine(T)) 95 84 static inline void resume(T & cor) { 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 ); 85 coroutine_desc * src = TL_GET( this_coroutine ); // optimization 102 86 coroutine_desc * dst = get_coroutine(cor); 103 87 … … 117 101 dst->last = src; 118 102 dst->starter = dst->starter ? dst->starter : src; 119 } 103 } // if 120 104 121 105 // always done for performance testing … … 124 108 125 109 static inline void resume(coroutine_desc * dst) { 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 ); 110 coroutine_desc * src = TL_GET( this_coroutine ); // optimization 132 111 133 112 // not resuming self ? … … 140 119 // set last resumer 141 120 dst->last = src; 142 } 121 } // if 143 122 144 123 // always done for performance testing
Note:
See TracChangeset
for help on using the changeset viewer.