File: atomic.go

package info (click to toggle)
golang-github-pion-ice.v2 2.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 684 kB
  • sloc: makefile: 5
file content (20 lines) | stat: -rw-r--r-- 423 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Package atomic contains custom atomic types
package atomic

import "sync/atomic"

// Error is an atomic error
type Error struct {
	v atomic.Value
}

// Store updates the value of the atomic variable
func (a *Error) Store(err error) {
	a.v.Store(struct{ error }{err})
}

// Load retrieves the current value of the atomic variable
func (a *Error) Load() error {
	err, _ := a.v.Load().(struct{ error })
	return err.error
}