add working signup + login

This commit is contained in:
sam 2023-09-04 03:33:13 +02:00
parent bc85b7c340
commit d8cb8c8fa8
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
27 changed files with 600 additions and 39 deletions

View file

@ -0,0 +1,30 @@
package concurrent
import "sync"
// Value is a struct providing concurrent access to another type.
// Note: T should be a concrete type, not a pointer.
type Value[T any] struct {
val T
mu sync.RWMutex
}
func NewValue[T any](value T) *Value[T] {
return &Value[T]{
val: value,
}
}
func (v *Value[T]) Get() T {
v.mu.RLock()
val := v.val
v.mu.RUnlock()
return val
}
func (v *Value[T]) Set(new T) {
v.mu.Lock()
v.val = new
v.mu.Unlock()
}