Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 20 May 2016 at 02:04:56 UTC, captaindet wrote: i am most curious about your solution. why does printAll() has a synchronized block? in case you would call it before thread_joinAll() i.e. before all threads are terminated? then again, why is there a synchronized block necessary in

Re: How to share an appender!string?

2016-05-19 Thread captaindet via Digitalmars-d-learn
On 2016-05-20 07:49, Era Scarecrow wrote: Experimented and quickly got what looks like good clean results. Took your code, ripped out what I didn't want and added in what I did. Simple! https://dpaste.dzfl.pl/6952fdf463b66 i am most curious about your solution. why does printAll() has a

Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 19 May 2016 at 19:31:26 UTC, Era Scarecrow wrote: An alternate to writing a custom appender is simply to make the assignment atomic. Haven't tried this but if you did 'shared string[] lines;' I'll experiment with this and get back with you. Multi-threading isn't my strong suit

Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 19 May 2016 at 13:33:50 UTC, Thorsten Sommer wrote: Issue analysis: My main issue was that the main() does not waited for the new thread (I used spawn() before I opened this discussion). Thus, a simple thread_joinAll(); solved that. Since each thread can run at different times

Re: How to share an appender!string?

2016-05-19 Thread Thorsten Sommer via Digitalmars-d-learn
Dear all, I am done :) Thanks @Kagamin, @Rene and @rikki for the help. Short answers: @Rene: You are right, I missed the starting of that task i.e. thread. Used before spawn() where the thread runs directly. But spawn() crashes dpaste.pl... @rikki: Yes, I known what you mentioned ;) I just

Re: How to share an appender!string?

2016-05-19 Thread Kagamin via Digitalmars-d-learn
I'd say do something like https://dpaste.dzfl.pl/e9a2327ff2a1 Any idea why it crashes?

Re: How to share an appender!string?

2016-05-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 May 2016 at 10:58:42 UTC, Rene Zwanenburg wrote: Calling task() only creates a Task, you also have to start it somehow. The documentation contains an example: https://dlang.org/phobos/std_parallelism.html#.task I should add that a single shared array will cause contention if

Re: How to share an appender!string?

2016-05-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/05/2016 10:41 PM, Thorsten Sommer wrote: On Thursday, 19 May 2016 at 10:13:21 UTC, rikki cattermole wrote: At this point I'd recommend you to just ignore Appender. Write your own. Dear rikki, Thanks for the proposal :) Here is the new attempt #4 as simple test case:

Re: How to share an appender!string?

2016-05-19 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 19 May 2016 at 10:41:14 UTC, Thorsten Sommer wrote: On Thursday, 19 May 2016 at 10:13:21 UTC, rikki cattermole wrote: At this point I'd recommend you to just ignore Appender. Write your own. Dear rikki, Thanks for the proposal :) Here is the new attempt #4 as simple test

Re: How to share an appender!string?

2016-05-19 Thread Thorsten Sommer via Digitalmars-d-learn
On Thursday, 19 May 2016 at 10:13:21 UTC, rikki cattermole wrote: At this point I'd recommend you to just ignore Appender. Write your own. Dear rikki, Thanks for the proposal :) Here is the new attempt #4 as simple test case: https://dpaste.dzfl.pl/f6a9663320e5 It compiles & runs, but the

Re: How to share an appender!string?

2016-05-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/05/2016 10:08 PM, Thorsten Sommer wrote: Dear community, I tried to create a kind of collector module which collects strings by using a shared appender!string. Why? To collect KPIs at a huge program across multiple classes and threads and store it later as e.g. CSV file in order to

How to share an appender!string?

2016-05-19 Thread Thorsten Sommer via Digitalmars-d-learn
Dear community, I tried to create a kind of collector module which collects strings by using a shared appender!string. Why? To collect KPIs at a huge program across multiple classes and threads and store it later as e.g. CSV file in order to analyse it by using R. But I failed... Attempt