Showing the changes to src/core/util_buffers.cpp (1 of 26 files). Show all
Unified · Split
| @@ -121,7 +121,9 @@ void CBufferAdvance::cleanup() · 120 unmodified lines | ||
| 121 | 121 | UINT__ CBufferAdvance::join( Chuck_Event * event ) |
| 122 | 122 | { |
| 123 | 123 | // TODO: necessary? |
| 124 | −// m_mutex.acquire(); | |
| 124 | + #ifndef __DISABLE_THREADS__ | |
| 125 | + m_mutex.acquire(); | |
| 126 | + #endif | |
| 125 | 127 | |
| 126 | 128 | // index of new pointer that will be pushed back |
| 127 | 129 | UINT__ read_offset_index; |
| @@ -143,7 +145,9 @@ UINT__ CBufferAdvance::join( Chuck_Event * event ) · 15 unmodified lines | ||
| 143 | 145 | } |
| 144 | 146 | |
| 145 | 147 | // TODO: necessary? |
| 146 | −// m_mutex.release(); | |
| 148 | + #ifndef __DISABLE_THREADS__ | |
| 149 | + m_mutex.release(); | |
| 150 | + #endif | |
| 147 | 151 | |
| 148 | 152 | // return index |
| 149 | 153 | return read_offset_index; |
| @@ -161,7 +165,9 @@ void CBufferAdvance::resign( UINT__ read_offset_index ) · 11 unmodified lines | ||
| 161 | 165 | return; |
| 162 | 166 | |
| 163 | 167 | // TODO: necessary? |
| 164 | −// m_mutex.acquire(); | |
| 168 | + #ifndef __DISABLE_THREADS__ | |
| 169 | + m_mutex.acquire(); | |
| 170 | + #endif | |
| 165 | 171 | |
| 166 | 172 | // add this index to free queue |
| 167 | 173 | m_free.push( read_offset_index ); |
| @@ -171,7 +177,9 @@ void CBufferAdvance::resign( UINT__ read_offset_index ) · 3 unmodified lines | ||
| 171 | 177 | m_read_offsets[read_offset_index].event = NULL; |
| 172 | 178 | |
| 173 | 179 | // TODO: necessary? |
| 174 | −// m_mutex.release(); | |
| 180 | + #ifndef __DISABLE_THREADS__ | |
| 181 | + m_mutex.release(); | |
| 182 | + #endif | |
| 175 | 183 | } |
| 176 | 184 | |
| 177 | 185 | |
| @@ -208,7 +216,9 @@ void CBufferAdvance::put( void * data, UINT__ num_elem ) · 30 unmodified lines | ||
| 208 | 216 | BYTE__ * d = (BYTE__ *)data; |
| 209 | 217 | |
| 210 | 218 | // TODO: necessary? |
| 211 | −// m_mutex.acquire(); | |
| 219 | + #ifndef __DISABLE_THREADS__ | |
| 220 | + m_mutex.acquire(); | |
| 221 | + #endif | |
| 212 | 222 | |
| 213 | 223 | // copy |
| 214 | 224 | for( i = 0; i < num_elem; i++ ) |
| @@ -240,7 +250,9 @@ void CBufferAdvance::put( void * data, UINT__ num_elem ) · 25 unmodified lines | ||
| 240 | 250 | } |
| 241 | 251 | |
| 242 | 252 | // TODO: necessary? |
| 243 | −// m_mutex.release(); | |
| 253 | + #ifndef __DISABLE_THREADS__ | |
| 254 | + m_mutex.release(); | |
| 255 | + #endif | |
| 244 | 256 | } |
| 245 | 257 | |
| 246 | 258 | |
| @@ -308,17 +320,23 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 61 unmodified lines | ||
| 308 | 320 | BYTE__ * d = (BYTE__ *)data; |
| 309 | 321 | |
| 310 | 322 | // TODO: necessary? |
| 311 | −// m_mutex.acquire(); | |
| 323 | + #ifndef __DISABLE_THREADS__ | |
| 324 | + m_mutex.acquire(); | |
| 325 | + #endif | |
| 312 | 326 | |
| 313 | 327 | // make sure index is valid |
| 314 | 328 | if( read_offset_index >= m_read_offsets.size() ) |
| 315 | 329 | { |
| 316 | −// m_mutex.release(); | |
| 330 | + #ifndef __DISABLE_THREADS__ | |
| 331 | + m_mutex.release(); | |
| 332 | + #endif | |
| 317 | 333 | return 0; |
| 318 | 334 | } |
| 319 | 335 | if( m_read_offsets[read_offset_index].read_offset < 0 ) |
| 320 | 336 | { |
| 321 | −// m_mutex.release(); | |
| 337 | + #ifndef __DISABLE_THREADS__ | |
| 338 | + m_mutex.release(); | |
| 339 | + #endif | |
| 322 | 340 | return 0; |
| 323 | 341 | } |
| 324 | 342 | |
| @@ -327,7 +345,9 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 2 unmodified lines | ||
| 327 | 345 | // read catch up with write |
| 328 | 346 | if( m_read_offset == m_write_offset ) |
| 329 | 347 | { |
| 330 | −// m_mutex.release(); | |
| 348 | + #ifndef __DISABLE_THREADS__ | |
| 349 | + m_mutex.release(); | |
| 350 | + #endif | |
| 331 | 351 | return 0; |
| 332 | 352 | } |
| 333 | 353 | |
| @@ -357,7 +377,9 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 23 unmodified lines | ||
| 357 | 377 | m_read_offsets[read_offset_index].read_offset = m_read_offset; |
| 358 | 378 | |
| 359 | 379 | // TODO: necessary? |
| 360 | −// m_mutex.release(); | |
| 380 | + #ifndef __DISABLE_THREADS__ | |
| 381 | + m_mutex.release(); | |
| 382 | + #endif | |
| 361 | 383 | |
| 362 | 384 | // return number of elems |
| 363 | 385 | return i; |