if (!ShouldReplicateObject(object))
return;
+ /* Don't replicate objects that haven't had any local updates. */
+ if (object->GetLocalTx() < tx)
+ return;
+
RequestMessage request = MakeObjectMessage(object, "config::ObjectUpdate", tx, true);
EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, request);
}
boost::signals2::signal<void (double, const DynamicObject::Ptr&)> DynamicObject::OnFlushObject;
DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject)
- : m_ConfigTx(0), m_Registered(false)
+ : m_ConfigTx(0), m_LocalTx(0), m_Registered(false)
{
RegisterAttribute("__name", Attribute_Config, &m_Name);
RegisterAttribute("__type", Attribute_Config, &m_Type);
if (it == m_Attributes.end())
BOOST_THROW_EXCEPTION(std::runtime_error("Touch() called for unknown attribute: " + name));
- it->second.SetTx(GetCurrentTx());
+ double tx = GetCurrentTx();
+ it->second.SetTx(tx);
+ m_LocalTx = tx;
m_ModifiedAttributes.insert(name);
}
}
+double DynamicObject::GetLocalTx(void) const
+{
+ boost::mutex::scoped_lock lock(m_AttributeMutex);
+ return m_LocalTx;
+}
+
Value DynamicObject::Get(const String& name) const
{
ASSERT(!OwnsLock());
virtual void Start(void);
virtual void Stop(void);
+ double GetLocalTx(void) const;
+
const AttributeMap& GetAttributes(void) const;
static DynamicObject::Ptr GetObject(const String& type, const String& name);
AttributeMap m_Attributes;
std::set<String, string_iless> m_ModifiedAttributes;
double m_ConfigTx;
+ double m_LocalTx;
Attribute<String> m_Name;
Attribute<String> m_Type;
*/
void FIFO::Optimize(void)
{
- //char *newBuffer;
-
if (m_DataSize < m_Offset) {
memcpy(m_Buffer, m_Buffer + m_Offset, m_DataSize);
m_Offset = 0;
- return;
- }
+ ResizeBuffer(m_DataSize);
- /*newBuffer = (char *)ResizeBuffer(NULL, 0, m_BufferSize - m_Offset);
-
- if (newBuffer == NULL)
return;
-
- memcpy(newBuffer, m_Buffer + m_Offset, m_BufferSize - m_Offset);
-
- free(m_Buffer);
- m_Buffer = newBuffer;
- m_BufferSize -= m_Offset;
- m_Offset = 0;*/
+ }
}
/**