You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 918264e
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: replace time.Time lastWrite with atomic Int64 for lock-free write timestamping
- Replace `lastWrite time.Time` with `lastWriteNano atomic.Int64` to enable lock-free updates in hot paths.
- Update maintenance logic to use monotonic nanoseconds instead of wall-clock time.
- Add `MarkWritten()` method for explicit write-timestamp updates.
- Remove `Rendering atomic.Bool` and associated logic, as it was redundant with the new timestamp mechanism.
- Delete obsolete test `TestRequest_JawsKeyReadsAreLockedDuringRecycle`, which is no longer relevant after lock-free JawsKey access removal.
Signed-off-by: Johan Lindh <johan@linkdata.se>
Copy file name to clipboardExpand all lines: request.go
+40-34Lines changed: 40 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -50,27 +50,26 @@ type ConnectFn = func(rq *Request) error
50
50
// [Request.Log] and [Request.MustLog] let it forward to the logger; both exist only for
51
51
// that diagnostic use, not as a public nil-safe contract.
52
52
typeRequeststruct {
53
-
Jaws*Jaws// (read-only) the JaWS instance the Request belongs to
54
-
JawsKey key.Key// (read-only) random key identifying this Request in the WebSocket URI and the broadcast/tail target; read under mu by the identity check (destKey, wantMessage) and the render path (JawsKeyString, HeadHTML)
55
-
remoteIP netip.Addr// (read-only) remote IP, or the zero netip.Addr if unset
56
-
Rendering atomic.Bool// set to true by RequestWriter.Write()
57
-
running atomic.Bool// if ServeHTTP() is running
58
-
claimed atomic.Bool// if UseRequest() has been called for it
59
-
mu deadlock.RWMutex// protects following
60
-
lastJidJid// last element Jid allocated within this Request
61
-
lastWrite time.Time// when the initial HTML was last written to, used for automatic cleanup
62
-
initial*http.Request// initial HTTP request passed to Jaws.NewRequest
63
-
session*Session// session, if established
64
-
todoDirt []any// dirty tags
65
-
ctx context.Context// current context, derived from either Jaws or WS HTTP req
66
-
httpDoneCh<-chanstruct{} // once claimed, set to http.Request.Context().Done()
67
-
cancelFn context.CancelCauseFunc// cancel function
68
-
connectFnConnectFn// a ConnectFn to call before starting message processing for the Request
69
-
elems []*Element// our Elements
70
-
tagMapmap[any][]*Element// maps tags to Elements
71
-
muQueue deadlock.Mutex// protects wsQueue and tailsent
72
-
wsQueue []wire.WsMsg// queued messages to send
73
-
tailsentbool
53
+
Jaws*Jaws// (read-only) the JaWS instance the Request belongs to
54
+
JawsKey key.Key// (read-only) random key identifying this Request in the WebSocket URI and the broadcast/tail target; read under mu by the identity check (destKey, wantMessage) and the render path (JawsKeyString, HeadHTML)
55
+
remoteIP netip.Addr// (read-only) remote IP, or the zero netip.Addr if unset
56
+
running atomic.Bool// if ServeHTTP() is running
57
+
claimed atomic.Bool// if UseRequest() has been called for it
58
+
lastWriteNano atomic.Int64// monotonic nanos (Jaws.nowNano) of the most recent RequestWriter write; lock-free, drives pending-eviction recency (oldestEvictablePendingLocked) and idle expiry (maintenance)
59
+
mu deadlock.RWMutex// protects following
60
+
lastJidJid// last element Jid allocated within this Request
61
+
initial*http.Request// initial HTTP request passed to Jaws.NewRequest
62
+
session*Session// session, if established
63
+
todoDirt []any// dirty tags
64
+
ctx context.Context// current context, derived from either Jaws or WS HTTP req
65
+
httpDoneCh<-chanstruct{} // once claimed, set to http.Request.Context().Done()
66
+
cancelFn context.CancelCauseFunc// cancel function
67
+
connectFnConnectFn// a ConnectFn to call before starting message processing for the Request
68
+
elems []*Element// our Elements
69
+
tagMapmap[any][]*Element// maps tags to Elements
70
+
muQueue deadlock.Mutex// protects wsQueue and tailsent
0 commit comments