Skip to content

Shared StringBuilder for incremental source generator? #74440

Closed Answered by CyrusNajmabadi
weifenluo asked this question in Q&A
Discussion options

You must be logged in to vote

What is the threading model of incremental source generator?

Everything should be assumed to be free-threaded and concurrent.

Can I use the same instance of internal StringBuilder for one source generator when generating multiple output files?

No.

If the source generator is invoked synchronized, this can have some performance gains.

Expect that everything is concurrent. Shared state is effectively verboten unless you are very careful to ensure it is absolutely safe.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants