Index: webrtc/test/channel_transport/udp_socket2_win.cc |
diff --git a/webrtc/test/channel_transport/udp_socket2_win.cc b/webrtc/test/channel_transport/udp_socket2_win.cc |
index 6bcb551012562cccbaa79c4dcd1d3cebc3b7f6fa..f4e9cf2da6236ffeafc1c475c974bacbefdb505a 100644 |
--- a/webrtc/test/channel_transport/udp_socket2_win.cc |
+++ b/webrtc/test/channel_transport/udp_socket2_win.cc |
@@ -14,6 +14,7 @@ |
#include <stdlib.h> |
#include <winsock2.h> |
+#include "webrtc/base/atomicops.h" |
#include "webrtc/base/format_macros.h" |
#include "webrtc/system_wrappers/interface/sleep.h" |
#include "webrtc/test/channel_transport/traffic_control_win.h" |
@@ -283,7 +284,7 @@ bool UdpSocket2Windows::StartReceiving(uint32_t receiveBuffers) |
_wantsIncoming = true; |
int32_t numberOfReceiveBuffersToCreate = |
- receiveBuffers - _receiveBuffers.Value(); |
+ receiveBuffers - rtc::AtomicOps::AcquireLoad(&_receiveBuffers); |
numberOfReceiveBuffersToCreate = (numberOfReceiveBuffersToCreate < 0) ? |
0 : numberOfReceiveBuffersToCreate; |
@@ -299,7 +300,7 @@ bool UdpSocket2Windows::StartReceiving(uint32_t receiveBuffers) |
error = -1; |
break; |
} |
- ++_receiveBuffers; |
+ rtc::AtomicOps::Increment(&_receiveBuffers); |
} |
if(error == -1) |
{ |
@@ -308,7 +309,7 @@ bool UdpSocket2Windows::StartReceiving(uint32_t receiveBuffers) |
WEBRTC_TRACE(kTraceDebug, kTraceTransport, _id, |
"Socket receiving using:%d number of buffers", |
- _receiveBuffers.Value()); |
+ rtc::AtomicOps::AcquireLoad(&_receiveBuffers)); |
return true; |
} |
@@ -473,7 +474,8 @@ void UdpSocket2Windows::IOCompleted(PerIoContext* pIOContext, |
} |
if(pIOContext) |
{ |
- int32_t remainingReceiveBuffers = --_receiveBuffers; |
+ int32_t remainingReceiveBuffers = |
+ rtc::AtomicOps::Decrement(&_receiveBuffers); |
if(remainingReceiveBuffers < 0) |
{ |
assert(false); |
@@ -628,7 +630,8 @@ int32_t UdpSocket2Windows::PostRecv(PerIoContext* pIoContext) |
{ |
return 0; |
} |
- int32_t remainingReceiveBuffers = --_receiveBuffers; |
+ int32_t remainingReceiveBuffers = |
+ rtc::AtomicOps::Decrement(&_receiveBuffers); |
if(remainingReceiveBuffers < 0) |
{ |
assert(false); |
@@ -1258,25 +1261,24 @@ bool UdpSocket2Windows::NewOutstandingCall() |
{ |
assert(!_outstandingCallsDisabled); |
- ++_outstandingCalls; |
+ rtc::AtomicOps::Increment(&_outstandingCalls); |
return true; |
} |
void UdpSocket2Windows::OutstandingCallCompleted() |
{ |
_ptrDestRWLock->AcquireLockShared(); |
- ++_outstandingCallComplete; |
- if((--_outstandingCalls == 0) && _outstandingCallsDisabled) |
- { |
+ rtc::AtomicOps::Increment(&_outstandingCallComplete); |
+ if ((rtc::AtomicOps::Decrement(&_outstandingCalls) == 0) && |
+ _outstandingCallsDisabled) { |
// When there are no outstanding calls and new outstanding calls are |
// disabled it is time to terminate. |
_terminate = true; |
} |
_ptrDestRWLock->ReleaseLockShared(); |
- if((--_outstandingCallComplete == 0) && |
- (_terminate)) |
- { |
+ if ((rtc::AtomicOps::Decrement(&_outstandingCallComplete) == 0) && |
+ (_terminate)) { |
// Only one thread will enter here. The thread with the last outstanding |
// call. |
CriticalSectionScoped cs(_ptrDeleteCrit); |
@@ -1295,7 +1297,8 @@ void UdpSocket2Windows::DisableNewOutstandingCalls() |
return; |
} |
_outstandingCallsDisabled = true; |
- const bool noOutstandingCalls = (_outstandingCalls.Value() == 0); |
+ const bool noOutstandingCalls = |
+ (rtc::AtomicOps::AcquireLoad(&_outstandingCalls) == 0); |
_ptrDestRWLock->ReleaseLockExclusive(); |
RemoveSocketFromManager(); |