MCPcopy Create free account
hub / github.com/aceld/zinx / doComplete

Method doComplete

zasync_op/async_op_result.go:66–82  ·  view source on GitHub ↗

doComplete executes the completion callback function, double-checking when setting the processing result and callback function to prevent the possibility of not calling the callback function (执行完成回调,在设置处理结果和回调函数的时候双重检查,杜绝未调用回调函数的可能性)

()

Source from the content-addressed store, hash-verified

64// doComplete executes the completion callback function, double-checking when setting the processing result and callback function to prevent the possibility of not calling the callback function
65// (执行完成回调,在设置处理结果和回调函数的时候双重检查,杜绝未调用回调函数的可能性)
66func (aor *AsyncOpResult) doComplete() {
67 v := aor.completeFunc.Load()
68 if v == nil {
69 return
70 }
71
72 cf := v.(func())
73
74 // Prevent re-entry problems (防止可重入问题)
75 if atomic.CompareAndSwapInt32(&aor.completeFuncHasAlreadyBeenCalled, 0, 1) {
76 // Prevent cross-thread calling problems,
77 // throw it to the corresponding business thread to execute
78 // (防止跨线程调用问题,扔到所属业务线程里去执行)
79 request := znet.NewFuncRequest(aor.conn, cf)
80 aor.conn.GetMsgHandler().SendMsgToTaskQueue(request)
81 }
82}
83
84// NewAsyncOpResult creates a new asynchronous result(新建异步结果)
85func NewAsyncOpResult(conn ziface.IConnection) *AsyncOpResult {

Callers 2

SetReturnedObjMethod · 0.95
OnCompleteMethod · 0.95

Calls 3

NewFuncRequestFunction · 0.92
SendMsgToTaskQueueMethod · 0.65
GetMsgHandlerMethod · 0.65

Tested by

no test coverage detected