MCPcopy Create free account
hub / github.com/cel-expr/cel-go / getOrCreate

Method getOrCreate

interpreter/async.go:218–243  ·  view source on GitHub ↗

getOrCreate returns the existing call state for the (node id, args) tuple, or registers and returns a new one. A newly registered call is assigned a unique callID and counted as pending.

(id int64, function, overload string, argVals []ref.Val, impl functions.AsyncOp, gate *asyncGate)

Source from the content-addressed store, hash-verified

216// getOrCreate returns the existing call state for the (node id, args) tuple, or registers and
217// returns a new one. A newly registered call is assigned a unique callID and counted as pending.
218func (t *asyncCallStateTracker) getOrCreate(id int64, function, overload string, argVals []ref.Val, impl functions.AsyncOp, gate *asyncGate) *asyncCallState {
219 key := hashCall(id, overload, argVals)
220
221 t.mu.RLock()
222 acs := findInBucket(t.calls[key], id, function, overload, argVals)
223 t.mu.RUnlock()
224 if acs != nil {
225 return acs
226 }
227
228 t.mu.Lock()
229 defer t.mu.Unlock()
230 // Check again in case it was created while waiting for the lock.
231 if acs := findInBucket(t.calls[key], id, function, overload, argVals); acs != nil {
232 return acs
233 }
234
235 // Assign a new unique call ID for this async call.
236 acs = newAsyncCallState(id, function, overload, argVals, impl)
237 callID := t.nextCallID.Add(1)
238 acs.callID = callID
239 acs.gate = gate
240 t.calls[key] = append(t.calls[key], acs)
241 t.callsByID[callID] = acs
242 return acs
243}
244
245func (t *asyncCallStateTracker) getByID(callID int64) *asyncCallState {
246 t.mu.RLock()

Calls 4

hashCallFunction · 0.85
findInBucketFunction · 0.85
newAsyncCallStateFunction · 0.85
AddMethod · 0.65