Skip to content

Conversation

@jamenai
Copy link

@jamenai jamenai commented Oct 9, 2025

Replace Dictionary with ConcurrentDictionary for attachments and add proper locking mechanisms for texture, wearables, and visual parameter fields to prevent race conditions in multi-threaded scenarios.

Key changes:

  • Use ConcurrentDictionary<int, List> for m_attachments
  • Add lock objects (m_textureLock, m_wearablesLock, m_visualParamsLock)
  • Protect all field access with appropriate locks
  • Optimize GetAttachments() to minimize lock duration
  • Fix potential collection modification exception in DetachAttachment()
  • Use snapshots in Pack()/Unpack() to avoid holding locks during I/O

Benefits:

  • Thread-safe read/write operations
  • Reduced lock contention through fine-grained locking
  • Better performance with concurrent dictionary for attachments
  • No API changes - fully backward compatible

Refs: #performance #thread-safety

Replace Dictionary with ConcurrentDictionary for attachments and add
proper locking mechanisms for texture, wearables, and visual parameter
fields to prevent race conditions in multi-threaded scenarios.

Key changes:
- Use ConcurrentDictionary<int, List<AvatarAttachment>> for m_attachments
- Add lock objects (m_textureLock, m_wearablesLock, m_visualParamsLock)
- Protect all field access with appropriate locks
- Optimize GetAttachments() to minimize lock duration
- Fix potential collection modification exception in DetachAttachment()
- Use snapshots in Pack()/Unpack() to avoid holding locks during I/O

Benefits:
- Thread-safe read/write operations
- Reduced lock contention through fine-grained locking
- Better performance with concurrent dictionary for attachments
- No API changes - fully backward compatible

Refs: #performance #thread-safety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant