[openrtm-commit:03201] r950 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 2月 28日 (水) 12:28:01 JST
Author: miyamoto
Date: 2018-02-28 12:28:01 +0900 (Wed, 28 Feb 2018)
New Revision: 950
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/RingBuffer.py
Log:
[bugfix, ->trunk] bug fixed. refs #4470
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/RingBuffer.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/RingBuffer.py 2018-02-28 00:38:29 UTC (rev 949)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/RingBuffer.py 2018-02-28 03:28:01 UTC (rev 950)
@@ -253,6 +253,8 @@
#
# ReturnCode advanceWptr(long int n = 1)
def advanceWptr(self, n = 1):
+ self._empty_cond.acquire()
+ empty = self.empty()
# n > 0 :
# n satisfies n <= writable elements
# n <= m_length - m_fillcout
@@ -267,6 +269,12 @@
self._wpos = (self._wpos + n + self._length) % self._length
self._fillcount += n
+
+
+ if empty:
+ self._empty_cond.notify()
+ self._empty_cond.release()
+
return OpenRTM_aist.BufferStatus.BUFFER_OK
@@ -349,6 +357,7 @@
def write(self, value, sec = -1, nsec = 0):
try:
self._full_cond.acquire()
+ self.full()
if self.full():
timedwrite = self._timedwrite # default is False
overwrite = self._overwrite # default is True
@@ -388,19 +397,11 @@
else: # unknown condition
self._full_cond.release()
return OpenRTM_aist.BufferStatus.PRECONDITION_NOT_MET
-
self._full_cond.release()
self.put(value)
- self._empty_cond.acquire()
- empty = self.empty()
- if empty:
- self.advanceWptr(1)
- self._empty_cond.notify()
- else:
- self.advanceWptr(1)
- self._empty_cond.release()
+ self.advanceWptr(1)
return OpenRTM_aist.BufferStatus.BUFFER_OK
except:
@@ -506,6 +507,8 @@
#
# DataType* rptr(long int n = 0)
def advanceRptr(self, n = 1):
+ self._full_cond.acquire()
+ full_ = self.full()
# n > 0 :
# n satisfies n <= readable elements
# n <= m_fillcout
@@ -519,6 +522,14 @@
self._rpos = (self._rpos + n + self._length) % self._length
self._fillcount -= n
+
+
+
+
+ if full_:
+ self._full_cond.notify()
+ self._full_cond.release()
+
return OpenRTM_aist.BufferStatus.BUFFER_OK
@@ -655,18 +666,9 @@
else:
value.append(val)
- self._full_cond.acquire()
- full_ = self.full()
+ self.advanceRptr()
- if full_:
- self.advanceRptr()
- self._full_cond.notify()
- else:
- self.advanceRptr()
- self._full_cond.release()
-
-
return OpenRTM_aist.BufferStatus.BUFFER_OK
More information about the openrtm-commit
mailing list