[ 
https://issues.apache.org/jira/browse/CSV-295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17505175#comment-17505175
 ] 

Zimo Li commented on CSV-295:
-----------------------------

[~ggregory] To answer your question, I'm a Scala programmer, and I use the ZIO 
framework all the time. Its Semaphore data type is just handy and solved my 
problem.

[~angusdev] I agree that changing the current behaviour of the CSVPrinter may 
not be necessary, and that will be a breaking change. Unfortunately, there's no 
AbstractCSVPrinter that a SynchronizedCSVPrinter can inherit from. Either way, 
I will benchmark the updated CSVPrinter. 
The overhead of synchronization only scales with the number of threads. It 
should be almost negligible for single-threaded applications.

> Support for parallelism in CSVPrinter
> -------------------------------------
>
>                 Key: CSV-295
>                 URL: https://issues.apache.org/jira/browse/CSV-295
>             Project: Commons CSV
>          Issue Type: Improvement
>          Components: Printer
>    Affects Versions: 1.9.0
>         Environment: 
> https://zio.dev/version-1.x/overview/overview_creating_effects#blocking-synchronous-side-effects
>            Reporter: Zimo Li
>            Priority: Major
>             Fix For: 1.10.0
>
>
> I am trying to write the result of network IO to a CSV file using Scala and 
> the ZIO library. The order of the rows does not matter, so I decided to use a 
> concurrency of 8.
> Each thread calls {{{}CSVPrinter.printRecord{}}}, and this caused some rows 
> to intersect with others. Eventually, I decided to use a 
> [Semaphore|https://zio.dev/version-1.x/datatypes/concurrency/semaphore] to 
> fix it.
> A locking mechanism for {{printRecord}} can be implemented just like the 
> underlying {{FileWriter}} or {{PrintWriter}}.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to