@Tamás Gulácsi: thank you for your review.
@Daniel K: yes, it was my original idea, but I quickly discarded it,
because I can't guarantee that LineAppender is safe for concurrent usage.
If you give it a wrong io.WriteCloser, it will be unsafe to use
concurrently.
Le mercredi 6 juillet 2016 12:4
Looks good, but you could take advantage of the io writer interface.
I made a quick example, not sure if it runs (did not test)
https://play.golang.org/p/cYcz2ktoiG
Den onsdag den 6. juli 2016 kl. 11.44.33 UTC+2 skrev Pierre Durand:
>
> My solution: https://play.golang.org/p/f5H0svLFE0
> What do
Seems ok.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ooops, fixed my code: https://play.golang.org/p/vdwDT9WMVr
Le mercredi 6 juillet 2016 11:44:33 UTC+2, Pierre Durand a écrit :
>
> My solution: https://play.golang.org/p/f5H0svLFE0
> What do you think ?
>
> Le mardi 5 juillet 2016 15:30:38 UTC+2, Jan Mercl a écrit :
>>
>>
>> On Tue, Jul 5, 2016 at
My solution: https://play.golang.org/p/f5H0svLFE0
What do you think ?
Le mardi 5 juillet 2016 15:30:38 UTC+2, Jan Mercl a écrit :
>
>
> On Tue, Jul 5, 2016 at 11:38 AM Pierre Durand > wrote:
>
> > It works as expected, but in my real code, I'd prefer to avoid mutex.
>
> Sounds like a case for usi
On Tue, Jul 5, 2016 at 11:38 AM Pierre Durand
wrote:
> It works as expected, but in my real code, I'd prefer to avoid mutex.
Sounds like a case for using a writer goroutine and sending it the
should-be-atomic log items via a chan string or chan []byte.
--
-j
--
You received this message b
On Tue, 5 Jul 2016 05:46:17 -0700 (PDT)
Pierre Durand wrote:
[...]
> My real question is: is there a problem in the *writeBuffer()*
> function ? It is very simple, and it looks that it works.
I'd not reinvent the wheel and use bufio.NewWriter() to wrap your file
object to a buffered writer. The
A better solution would be to compose a new Writer wrapping the existing one
with a mutex.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr..
@Dave Cheney: I want to avoid a *global* mutex, because my function can
write to different files.
@Konstantin Khomoutov: You are right, I could use a map of mutexes.
As Alex Bligh said, I also need to add a mutex on this map, which is a bit
complicated...
I'm not using concurrency to write fast
> On 5 Jul 2016, at 10:38, Pierre Durand wrote:
>
> So, I've written writeMutex(), that uses a mutex.
> It works as expected, but in my real code, I'd prefer to avoid mutex.
> (in my real code write() can write to different files; the file's name is
> given as argument)
... or more idiomatical
> On 5 Jul 2016, at 10:38, Pierre Durand wrote:
>
> Hello!
>
> My code: https://play.golang.org/p/pg-p17UuEW
> I'm trying to append lines to a file concurrently.
>
> My first write() function is buggy, because WriteString() are called by
> several goroutines in unexpected order.
>
> So, I've
On Tue, 5 Jul 2016 02:38:28 -0700 (PDT)
Pierre Durand wrote:
> My code: https://play.golang.org/p/pg-p17UuEW
> I'm trying to append lines to a file concurrently.
>
> My first write() function is buggy, because WriteString() are called
> by several goroutines in unexpected order.
>
> So, I've wr
Why do you want to avoid a mutex?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups
Hello!
My code: https://play.golang.org/p/pg-p17UuEW
I'm trying to append lines to a file concurrently.
My first write() function is buggy, because WriteString() are called by
several goroutines in unexpected order.
So, I've written writeMutex(), that uses a mutex.
It works as expected, but in
14 matches
Mail list logo