X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=blobdiff_plain;f=dali%2Fintegration-api%2Flockless-buffer.cpp;h=b704dbc3b0a6cd4645b23d6892335349a3d0333c;hp=a1a7541a5991a7f8f3c8a71438ea0410823d6b7a;hb=649ec06daecb510fb84fe4642a6af957f127e7ab;hpb=88c06f8cdea30606c625dd3a7aecb0df8652af72 diff --git a/dali/integration-api/lockless-buffer.cpp b/dali/integration-api/lockless-buffer.cpp index a1a7541..b704dbc 100644 --- a/dali/integration-api/lockless-buffer.cpp +++ b/dali/integration-api/lockless-buffer.cpp @@ -50,8 +50,7 @@ void LocklessBuffer::Write( const unsigned char *src, size_t size ) DALI_ASSERT_ALWAYS( size <= mSize ); // set WRITING bit - BufferState currentState( std::atomic_fetch_or( &mState, WRITING ) ); - + BufferState currentState( __sync_fetch_and_or( &mState, WRITING ) ); DALI_ASSERT_DEBUG( !(currentState & WRITING_MASK) ); // WRITING bit should never be set when we get here // copy data to current write buffer, negate state to get actual index (recap: R0W1 = 0, R1W0 = 1) @@ -59,9 +58,9 @@ void LocklessBuffer::Write( const unsigned char *src, size_t size ) memcpy( mBuffer[index], src, size ); // unset WRITING bit, set UPDATED bit - BufferState writingState = static_cast(currentState | WRITING); - BufferState checkState = mState; - mState.compare_exchange_strong( writingState, static_cast(index | UPDATED) ); + BufferState checkState = __sync_val_compare_and_swap( &mState, + static_cast(currentState | WRITING), + static_cast(index | UPDATED) ); DALI_ASSERT_DEBUG( checkState & WRITING ); (void)checkState; // Avoid unused variable warning @@ -77,8 +76,9 @@ const unsigned char* LocklessBuffer::Read() { // Try to swap buffers. // This will set mState to 1 if readbuffer 0 was updated, 0 if readbuffer 1 was updated and fail if WRITING is set - BufferState writingState = static_cast(currentWriteBuf | UPDATED); - if( mState.compare_exchange_strong( writingState, static_cast(!currentWriteBuf) ) ) + if( __sync_bool_compare_and_swap( &mState, + static_cast(currentWriteBuf | UPDATED), + static_cast(!currentWriteBuf) ) ) { // swap successful return mBuffer[currentWriteBuf];