|
9 | 9 | "syscall" |
10 | 10 | "time" |
11 | 11 |
|
12 | | - sync_atomic "sync/atomic" |
13 | | - |
14 | 12 | "github.com/ozontech/file.d/logger" |
15 | 13 | "github.com/ozontech/file.d/pipeline" |
16 | 14 | "github.com/ozontech/file.d/xtime" |
@@ -104,37 +102,38 @@ func (j *Job) seek(offset int64, whence int, hint string) (n int64) { |
104 | 102 | return n |
105 | 103 | } |
106 | 104 |
|
| 105 | +// eofInfo tracks end-of-file state for read operations. |
| 106 | +// Used to determine when files can be safely removed after processing. |
107 | 107 | type eofInfo struct { |
108 | | - timestamp int64 |
109 | | - offset int64 |
| 108 | + timestamp atomic.Int64 |
| 109 | + offset atomic.Int64 |
110 | 110 | } |
111 | 111 |
|
112 | 112 | func (e *eofInfo) setTimestamp(t time.Time) { |
113 | | - sync_atomic.StoreInt64(&e.timestamp, t.UnixNano()) |
| 113 | + e.timestamp.Store(t.UnixNano()) |
114 | 114 | } |
115 | 115 |
|
116 | 116 | func (e *eofInfo) getTimestamp() time.Time { |
117 | | - nanos := sync_atomic.LoadInt64(&e.timestamp) |
| 117 | + nanos := e.timestamp.Load() |
118 | 118 | return time.Unix(0, nanos) |
119 | 119 | } |
120 | 120 |
|
121 | 121 | // setUnixNanoTimestamp sets timestamp in seconds |
122 | 122 | func (e *eofInfo) setUnixNanoTimestamp(nanos int64) { |
123 | | - sync_atomic.StoreInt64(&e.timestamp, nanos) |
| 123 | + e.timestamp.Store(nanos) |
124 | 124 | } |
125 | 125 |
|
126 | 126 | // getUnixNanoTimestamp returns timestamp in seconds |
127 | 127 | func (e *eofInfo) getUnixNanoTimestamp() int64 { |
128 | | - nanos := sync_atomic.LoadInt64(&e.timestamp) |
129 | | - return nanos |
| 128 | + return e.timestamp.Load() |
130 | 129 | } |
131 | 130 |
|
132 | 131 | func (e *eofInfo) setOffset(offset int64) { |
133 | | - sync_atomic.StoreInt64(&e.offset, offset) |
| 132 | + e.offset.Store(offset) |
134 | 133 | } |
135 | 134 |
|
136 | 135 | func (e *eofInfo) getOffset() int64 { |
137 | | - return sync_atomic.LoadInt64(&e.offset) |
| 136 | + return e.offset.Load() |
138 | 137 | } |
139 | 138 |
|
140 | 139 | type inodeID uint64 |
|
0 commit comments