- File:
-
- 1 edited
-
libcfa/src/concurrency/mutex.cfa (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/mutex.cfa
rbe73f30 r121be3e 30 30 this.lock{}; 31 31 this.blocked_threads{}; 32 this.is_locked = false;33 32 } 34 33 … … 40 39 lock( lock __cfaabi_dbg_ctx2 ); 41 40 if( is_locked ) { 42 append( blocked_threads, active_thread() ); 43 unlock( lock ); 44 park(); 41 append( blocked_threads, kernelTLS.this_thread ); 42 BlockInternal( &lock ); 45 43 } 46 44 else { … … 64 62 lock( this.lock __cfaabi_dbg_ctx2 ); 65 63 this.is_locked = (this.blocked_threads != 0); 66 unpark(64 WakeThread( 67 65 pop_head( this.blocked_threads ) 68 66 ); … … 86 84 lock( lock __cfaabi_dbg_ctx2 ); 87 85 if( owner == 0p ) { 88 owner = active_thread();86 owner = kernelTLS.this_thread; 89 87 recursion_count = 1; 90 88 unlock( lock ); 91 89 } 92 else if( owner == active_thread()) {90 else if( owner == kernelTLS.this_thread ) { 93 91 recursion_count++; 94 92 unlock( lock ); 95 93 } 96 94 else { 97 append( blocked_threads, active_thread() ); 98 unlock( lock ); 99 park(); 95 append( blocked_threads, kernelTLS.this_thread ); 96 BlockInternal( &lock ); 100 97 } 101 98 } … … 105 102 lock( lock __cfaabi_dbg_ctx2 ); 106 103 if( owner == 0p ) { 107 owner = active_thread();104 owner = kernelTLS.this_thread; 108 105 recursion_count = 1; 109 106 ret = true; 110 107 } 111 else if( owner == active_thread()) {108 else if( owner == kernelTLS.this_thread ) { 112 109 recursion_count++; 113 110 ret = true; … … 121 118 recursion_count--; 122 119 if( recursion_count == 0 ) { 123 $thread* thrd = pop_head( blocked_threads );120 thread_desc * thrd = pop_head( blocked_threads ); 124 121 owner = thrd; 125 122 recursion_count = (thrd ? 1 : 0); 126 unpark( thrd );123 WakeThread( thrd ); 127 124 } 128 125 unlock( lock ); … … 141 138 void notify_one(condition_variable & this) with(this) { 142 139 lock( lock __cfaabi_dbg_ctx2 ); 143 unpark(140 WakeThread( 144 141 pop_head( this.blocked_threads ) 145 142 ); … … 150 147 lock( lock __cfaabi_dbg_ctx2 ); 151 148 while(this.blocked_threads) { 152 unpark(149 WakeThread( 153 150 pop_head( this.blocked_threads ) 154 151 ); … … 159 156 void wait(condition_variable & this) { 160 157 lock( this.lock __cfaabi_dbg_ctx2 ); 161 append( this.blocked_threads, active_thread() ); 162 unlock( this.lock ); 163 park(); 158 append( this.blocked_threads, kernelTLS.this_thread ); 159 BlockInternal( &this.lock ); 164 160 } 165 161 … … 167 163 void wait(condition_variable & this, L & l) { 168 164 lock( this.lock __cfaabi_dbg_ctx2 ); 169 append( this.blocked_threads, active_thread() ); 170 unlock(l); 171 unlock(this.lock); 172 park(); 165 append( this.blocked_threads, kernelTLS.this_thread ); 166 void __unlock(void) { 167 unlock(l); 168 unlock(this.lock); 169 } 170 BlockInternal( __unlock ); 173 171 lock(l); 174 172 }
Note:
See TracChangeset
for help on using the changeset viewer.