MCPcopy Index your code
hub / github.com/coder/coder / run

Method run

coderd/database/pubsub/pubsub.go:91–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89}
90
91func (q *MsgQueue) run() {
92 for {
93 // wait until there is something on the queue or we are closed
94 q.cond.L.Lock()
95 for q.size == 0 && !q.closed {
96 q.cond.Wait()
97 }
98 if q.closed {
99 q.cond.L.Unlock()
100 return
101 }
102 item := q.q[q.front]
103 q.front = (q.front + 1) % BufferSize
104 q.size--
105 q.cond.L.Unlock()
106
107 // process item without holding lock
108 if item.err == nil {
109 // real message
110 if q.l != nil {
111 q.l(q.ctx, item.msg)
112 continue
113 }
114 if q.le != nil {
115 q.le(q.ctx, item.msg, nil)
116 continue
117 }
118 // unhittable
119 continue
120 }
121 // if the listener wants errors, send it.
122 if q.le != nil {
123 q.le(q.ctx, nil, item.err)
124 }
125 }
126}
127
128func (q *MsgQueue) Enqueue(msg []byte) {
129 q.cond.L.Lock()

Callers 4

NewMsgQueueFunction · 0.95
TestPurgeChatDebugRunsFunction · 0.45
TestDeleteOldChatFilesFunction · 0.45

Calls 3

WaitMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 3

TestPurgeChatDebugRunsFunction · 0.36
TestDeleteOldChatFilesFunction · 0.36