| 516 | } |
| 517 | |
| 518 | void *asCScriptObject::GetUserData(asPWORD type) const |
| 519 | { |
| 520 | if( !extra ) |
| 521 | return 0; |
| 522 | |
| 523 | // There may be multiple threads reading, but when |
| 524 | // setting the user data nobody must be reading. |
| 525 | // TODO: runtime optimize: Would it be worth it to have a rwlock per object type? |
| 526 | asAcquireSharedLock(); |
| 527 | |
| 528 | for( asUINT n = 0; n < extra->userData.GetLength(); n += 2 ) |
| 529 | { |
| 530 | if( extra->userData[n] == type ) |
| 531 | { |
| 532 | void *userData = reinterpret_cast<void*>(extra->userData[n+1]); |
| 533 | asReleaseSharedLock(); |
| 534 | return userData; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | asReleaseSharedLock(); |
| 539 | |
| 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | void *asCScriptObject::SetUserData(void *data, asPWORD type) |
| 544 | { |
nothing calls this directly
no test coverage detected