MCPcopy Index your code
hub / github.com/Shopify/go-lua / CallWithContinuation

Method CallWithContinuation

lua.go:334–352  ·  view source on GitHub ↗

CallWithContinuation is exactly like Call, but allows the called function to yield. http://www.lua.org/manual/5.2/manual.html#lua_callk

(argCount, resultCount, context int, continuation Function)

Source from the content-addressed store, hash-verified

332//
333// http://www.lua.org/manual/5.2/manual.html#lua_callk
334func (l *State) CallWithContinuation(argCount, resultCount, context int, continuation Function) {
335 if apiCheck && continuation != nil && l.callInfo.isLua() {
336 panic("cannot use continuations inside hooks")
337 }
338 l.checkElementCount(argCount + 1)
339 if apiCheck && l.shouldYield {
340 panic("cannot do calls on non-normal thread")
341 }
342 l.checkResults(argCount, resultCount)
343 f := l.top - (argCount + 1)
344 if continuation != nil && l.nonYieldableCallCount == 0 { // need to prepare continuation?
345 l.callInfo.continuation = continuation
346 l.callInfo.context = context
347 l.call(f, resultCount, true) // just do the call
348 } else { // no continuation or not yieldable
349 l.call(f, resultCount, false) // just do the call
350 }
351 l.adjustResults(resultCount)
352}
353
354// ProtectedCall calls a function in protected mode. Both argCount and
355// resultCount have the same meaning as in Call. If there are no errors

Callers 2

CallMethod · 0.95
base.goFile · 0.80

Calls 5

checkElementCountMethod · 0.95
checkResultsMethod · 0.95
callMethod · 0.95
adjustResultsMethod · 0.95
isLuaMethod · 0.80

Tested by

no test coverage detected