Skip to content

Commit 2aeec12

Browse files
committed
Deprecate common/atomic
1 parent 40f0297 commit 2aeec12

14 files changed

Lines changed: 75 additions & 48 deletions

File tree

common/atomic/typed.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/sagernet/sing/common"
77
)
88

9+
// Deprecated: moved to common.TypedValue
910
type TypedValue[T any] atomic.Pointer[T]
1011

1112
func (t *TypedValue[T]) Load() T {

common/atomic/types.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
//go:build go1.24
2-
31
package atomic
42

53
import "sync/atomic"
64

75
type (
8-
Bool = atomic.Bool
9-
Int32 = atomic.Int32
10-
Int64 = atomic.Int64
11-
Uint32 = atomic.Uint32
12-
Uint64 = atomic.Uint64
13-
Uintptr = atomic.Uintptr
14-
Value = atomic.Value
15-
Pointer[T any] = atomic.Pointer[T]
6+
// Deprecated: use sync/atomic instead
7+
Bool = atomic.Bool
8+
// Deprecated: use sync/atomic instead
9+
Int32 = atomic.Int32
10+
// Deprecated: use sync/atomic instead
11+
Int64 = atomic.Int64
12+
// Deprecated: use sync/atomic instead
13+
Uint32 = atomic.Uint32
14+
// Deprecated: use sync/atomic instead
15+
Uint64 = atomic.Uint64
16+
// Deprecated: use sync/atomic instead
17+
Uintptr = atomic.Uintptr
18+
// Deprecated: use sync/atomic instead
19+
Value = atomic.Value
1620
)
1721

18-
func PointerForm[T any](p *atomic.Pointer[T]) *Pointer[T] {
19-
return p
22+
// Deprecated: use sync/atomic instead
23+
type Pointer[T any] struct {
24+
atomic.Pointer[T]
2025
}

common/atomic/types_compat.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

common/buf/buffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"crypto/rand"
55
"io"
66
"net"
7+
"sync/atomic"
78

89
"github.com/sagernet/sing/common"
9-
"github.com/sagernet/sing/common/atomic"
1010
"github.com/sagernet/sing/common/debug"
1111
E "github.com/sagernet/sing/common/exceptions"
1212
F "github.com/sagernet/sing/common/format"

common/bufio/counter_conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package bufio
33
import (
44
"io"
55
"net"
6+
"sync/atomic"
67

78
"github.com/sagernet/sing/common"
8-
"github.com/sagernet/sing/common/atomic"
99
"github.com/sagernet/sing/common/buf"
1010
N "github.com/sagernet/sing/common/network"
1111
)

common/bufio/counter_packet_conn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package bufio
22

33
import (
4+
"sync/atomic"
5+
46
"github.com/sagernet/sing/common"
5-
"github.com/sagernet/sing/common/atomic"
67
"github.com/sagernet/sing/common/buf"
78
M "github.com/sagernet/sing/common/metadata"
89
N "github.com/sagernet/sing/common/network"

common/bufio/deadline/packet_reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/sagernet/sing/common/atomic"
8+
"github.com/sagernet/sing/common"
99
"github.com/sagernet/sing/common/buf"
1010
M "github.com/sagernet/sing/common/metadata"
1111
N "github.com/sagernet/sing/common/network"
@@ -24,7 +24,7 @@ type PacketReader interface {
2424

2525
type packetReader struct {
2626
TimeoutPacketReader
27-
deadline atomic.TypedValue[time.Time]
27+
deadline common.TypedValue[time.Time]
2828
pipeDeadline pipeDeadline
2929
result chan *packetReadResult
3030
done chan struct{}

common/bufio/deadline/packet_reader_fallback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package deadline
33
import (
44
"net"
55
"os"
6+
"sync/atomic"
67
"time"
78

8-
"github.com/sagernet/sing/common/atomic"
99
"github.com/sagernet/sing/common/buf"
1010
M "github.com/sagernet/sing/common/metadata"
1111
)

common/bufio/deadline/reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/sagernet/sing/common/atomic"
8+
"github.com/sagernet/sing/common"
99
"github.com/sagernet/sing/common/buf"
1010
"github.com/sagernet/sing/common/bufio"
1111
N "github.com/sagernet/sing/common/network"
@@ -26,7 +26,7 @@ type Reader interface {
2626
type reader struct {
2727
N.ExtendedReader
2828
timeoutReader TimeoutReader
29-
deadline atomic.TypedValue[time.Time]
29+
deadline common.TypedValue[time.Time]
3030
pipeDeadline pipeDeadline
3131
result chan *readResult
3232
done chan struct{}

common/bufio/deadline/reader_fallback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package deadline
22

33
import (
44
"os"
5+
"sync/atomic"
56
"time"
67

7-
"github.com/sagernet/sing/common/atomic"
88
"github.com/sagernet/sing/common/buf"
99
)
1010

0 commit comments

Comments
 (0)