...

/

Tasks and Worker Processes

Tasks and Worker Processes

This lesson lists the possible ways of communication and their pros and cons in different situations.

Suppose we have to perform several tasks; a task is performed by a worker (process). A Task can be defined as a struct (the concrete details are not important here):

type Task struct {
  // some state
}

1st paradigm: use shared memory to synchronize

The pool of tasks is shared memory. To synchronize the work and to avoid race conditions, we have to guard the pool with a Mutex ...