Skip to content

Add overloaded saveAll method to store collection of entities#25

Merged
bytefish merged 2 commits intobytefish:masterfrom
kowalczm:master
Nov 25, 2018
Merged

Add overloaded saveAll method to store collection of entities#25
bytefish merged 2 commits intobytefish:masterfrom
kowalczm:master

Conversation

@kowalczm
Copy link
Copy Markdown

@kowalczm kowalczm commented Nov 25, 2018

Allow to store not just streams
Avoid synchronization

@bytefish
Copy link
Copy Markdown
Owner

What's the reason for not using the synchronized access for the Collection overload? I am afraid the same PgBulkInsert instance is used by multiple threads, and the concurrent access to the BinaryWriter may cause problems.

@kowalczm
Copy link
Copy Markdown
Author

kowalczm commented Nov 25, 2018

Generally it is performance reason not to synchronize when not required.
I think it should not be a problem as in saveAll method there is created new instance of PgBinaryWriter for each call. Even if PgBulkInsert could be used by multipe threads but we assume that each thread is using own connection. I think that synchronized was used only for parallel streams?

@bytefish
Copy link
Copy Markdown
Owner

You are totally right! It opens its own writer, so it shouldn't be a problem. I will merge your code and release it later today. 🤝

@bytefish bytefish merged commit 7105a1a into bytefish:master Nov 25, 2018
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