DynamicType::DynamicType(const String& name)
: m_Name(name)
-{ }
+{
+ InflateMutex();
+}
DynamicType::Ptr DynamicType::GetByName(const String& name)
{
}
#endif /* _DEBUG */
+void Object::InflateMutex(void)
+{
+ m_Mutex.Inflate();
+}
+
void Object::SetField(int, const Value&)
{
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid field ID."));
bool OwnsLock(void) const;
#endif /* _DEBUG */
+ void InflateMutex(void);
+
private:
Object(const Object& other);
Object& operator=(const Object& rhs);
#endif /* _DEBUG */
}
- inline void Spin(unsigned int it)
- {
- if (it < 8) {
- /* Do nothing. */
- }
-#ifdef SPIN_PAUSE
- else if (it < 16) {
- SPIN_PAUSE();
- }
-#endif /* SPIN_PAUSE */
- else {
-#ifdef _WIN32
- Sleep(0);
-#else /* _WIN32 */
- sched_yield();
-#endif /* _WIN32 */
- }
- }
-
- inline void Lock(void)
+ inline void Lock(bool make_native = false)
{
bool contended = false;
unsigned int it = 0;
it++;
}
- if (contended)
+ if (contended || make_native)
MakeNative();
}
- void MakeNative(void);
- void DestroyNative(void);
-
- void LockNative(void);
- void UnlockNative(void);
-
inline void Unlock(void)
{
#ifdef _WIN32
UnlockNative();
}
+ inline void Inflate(void)
+ {
+ Lock(true);
+ Unlock();
+ }
+
#ifdef _DEBUG
static void DebugTimerHandler(void);
#endif /* _DEBUG */
+private:
+ inline void Spin(unsigned int it)
+ {
+ if (it < 8) {
+ /* Do nothing. */
+ }
+#ifdef SPIN_PAUSE
+ else if (it < 16) {
+ SPIN_PAUSE();
+ }
+#endif /* SPIN_PAUSE */
+ else {
+#ifdef _WIN32
+ DebugBreak();
+ Sleep(0);
+#else /* _WIN32 */
+ sched_yield();
+#endif /* _WIN32 */
+ }
+ }
+
+ void MakeNative(void);
+ void DestroyNative(void);
+
+ void LockNative(void);
+ void UnlockNative(void);
+
private:
#ifdef _WIN32
# ifdef _WIN64
/* Make sure the type is valid. */
Type::Ptr type = Type::GetByName(GetType());
-
- if (!type || !Type::GetByName("DynamicObject")->IsAssignableFrom(type))
- BOOST_THROW_EXCEPTION(ConfigError("Type '" + GetType() + "' does not exist."));
+ ASSERT(type && Type::GetByName("DynamicObject")->IsAssignableFrom(type));
if (IsAbstract())
return DynamicObject::Ptr();
locals->Set("name", m_Name);
dobj->SetParentScope(locals);
+ locals.reset();
DebugHint debugHints;
if (discard)
m_Expression.reset();
- dobj->SetParentScope(Dictionary::Ptr());
+ dobj->SetParentScope(Object::Ptr());
String name = m_Name;
persistentItem->Set("debug_hints", debugHints.ToDictionary());
ConfigCompilerContext::GetInstance()->WriteObject(persistentItem);
+ persistentItem.reset();
ConfigType::Ptr ctype = ConfigType::GetByName(GetType());
bool m_Abstract; /**< Whether this is a template. */
boost::shared_ptr<Expression> m_Expression;
- std::vector<String> m_ParentNames; /**< The names of parent configuration
- items. */
DebugInfo m_DebugInfo; /**< Debug information. */
Object::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */
if (parent) {
AddParentRules(ruleLists, parent);
-
- ObjectLock plock(parent);
ruleLists.push_back(parent->m_RuleList);
}
}