September 2017
Intermediate to advanced
466 pages
9h 33m
English
The good thing with shared memory and mutexes is that, in theory, they usually take a very small amount of the code, which means that the rest of the code can work concurrently without any other delays. However, only after you have implemented something can you see what really happens!
The name of this implementation will be WCshared.go and will be presented in five parts: the first part of the utility is the following:
package main
import (
"bufio"
"fmt"
"io"
"os"
"path/filepath"
"regexp"
"sync"
)
type File struct {
Filename string
Lines int
Words int
Characters int
Error error
}
var aM sync.Mutex
var values = make([]File, 0)
The values slice will be the shared variable of the program whereas the name of the mutex variable ...
Read now
Unlock full access