Skip to content

Feature: Add WrapAsThreadSafe#184

Open
mai7star wants to merge 1 commit into
deckarep:mainfrom
mai7star:feature/WrapAsThreadSafe
Open

Feature: Add WrapAsThreadSafe#184
mai7star wants to merge 1 commit into
deckarep:mainfrom
mai7star:feature/WrapAsThreadSafe

Conversation

@mai7star

Copy link
Copy Markdown
Contributor

Overview

  • Added WrapAsThreadSafe() function
    • Upgrades threadUnsafeSet to threadSafeSet
    • Intended for use cases where initial data is populated under concurrent processing, then used as read-only afterward

Example

set := NewThreadUnsafeSet[int]()

// Add items to safeSet under concurrent processing (thread-safe here)
safeSet = WrapAsThreadSafe(set) 
safeSet.Append(i1, i2, i3...)

// Read operations on the original set
set.Contains(1)

@deckarep

Copy link
Copy Markdown
Owner

Just how useful is this for others out there? I'm not opposed to it but I'm also not sure that I want to go down this path.

It's not the kind of thing you blindly want to mix and match.

Example: doing operations with a threadsafe Set and a non-threadsafe are not compatible.

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.

2 participants