package my_sync

import "sync"

type Counter struct {
	// mutual exclusion lock. Zero value is an unlocked Mutex

	// If we embedded the type it would be c.Lock() but that also makes all other
	// Mutex functions part of the public interface, which we don't want.
	// sync.Mutex
	mu    sync.Mutex
	count int
}

func (c *Counter) Inc() {
	c.mu.Lock()
	defer c.mu.Unlock()
	c.count++
}

func (c *Counter) Value() int {
	return c.count
}
