interface
| 136 | |
| 137 | // interface |
| 138 | void *asCModule::SetUserData(void *data, asPWORD type) |
| 139 | { |
| 140 | // As a thread might add a new new user data at the same time as another |
| 141 | // it is necessary to protect both read and write access to the userData member |
| 142 | ACQUIREEXCLUSIVE(m_engine->engineRWLock); |
| 143 | |
| 144 | // It is not intended to store a lot of different types of userdata, |
| 145 | // so a more complex structure like a associative map would just have |
| 146 | // more overhead than a simple array. |
| 147 | for( asUINT n = 0; n < m_userData.GetLength(); n += 2 ) |
| 148 | { |
| 149 | if( m_userData[n] == type ) |
| 150 | { |
| 151 | void *oldData = reinterpret_cast<void*>(m_userData[n+1]); |
| 152 | m_userData[n+1] = reinterpret_cast<asPWORD>(data); |
| 153 | |
| 154 | RELEASEEXCLUSIVE(m_engine->engineRWLock); |
| 155 | |
| 156 | return oldData; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | m_userData.PushLast(type); |
| 161 | m_userData.PushLast(reinterpret_cast<asPWORD>(data)); |
| 162 | |
| 163 | RELEASEEXCLUSIVE(m_engine->engineRWLock); |
| 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | // interface |
| 169 | void *asCModule::GetUserData(asPWORD type) const |