MCPcopy Create free account
hub / github.com/buke/quickjs-go / SetInterruptHandler

Method SetInterruptHandler

runtime.go:943–967  ·  view source on GitHub ↗

SetInterruptHandler sets a user interrupt handler using simplified approach. This will override any timeout handler (expected behavior)

(handler InterruptHandler)

Source from the content-addressed store, hash-verified

941// SetInterruptHandler sets a user interrupt handler using simplified approach.
942// This will override any timeout handler (expected behavior)
943func (r *Runtime) SetInterruptHandler(handler InterruptHandler) {
944 if r == nil {
945 return
946 }
947 if !r.ensureOwnerAccess() {
948 return
949 }
950 r.mu.Lock()
951 defer r.mu.Unlock()
952 if r.closed.Load() || r.ref == nil {
953 return
954 }
955 if handler != nil {
956 r.interruptHandlerState.Store(&interruptHandlerHolder{fn: handler})
957 } else {
958 r.interruptHandlerState.Store(nil)
959 }
960
961 if handler != nil {
962 // Simplified call - no handlerArgs complexity
963 C.SetInterruptHandler(r.ref)
964 } else {
965 C.ClearInterruptHandler(r.ref)
966 }
967}
968
969// ClearInterruptHandler clears the user interrupt handler
970func (r *Runtime) ClearInterruptHandler() {

Calls 4

ensureOwnerAccessMethod · 0.95
LoadMethod · 0.80
StoreMethod · 0.80
ClearInterruptHandlerMethod · 0.80