V
V
vgrabkowot2020-07-30 19:45:48
go
vgrabkowot, 2020-07-30 19:45:48

Have I written the test for multi-threading correctly?

When I tried to work with files in Go through ioutil, I realized that it was not thread-safe, long googling somehow did not help me and I decided to build a bicycle. The bottom line is that we have a map that stores a mutex for each file with which the package has ever worked and, while reading from the file, blocks it at the logic level using RLock () well, when writing Lock () itself, and it even performs the task .

When I tried to write tests, this is what came out .
I don't like what happened and it seems like a wild govnokod. Can this be done better/more elegantly?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question