Concurrencyrecord(account, overdraft_of(transaction)); notify_user(account, overdraft_message); reject_transaction(transaction); } Needs synchronization https://godbolt.org/z/YhdcjncYoCppCon 2023 record(account, overdraft_of(transaction)); notify_user(account, overdraft_message); reject_transaction(transaction); } Needs synchronization Data race! https://godbolt.org/z/YhdcjncYoCppCon record(account, overdraft_of(transaction)); notify_user(account, overdraft_message); reject_transaction(transaction); } Incomplete synchronization https://godbolt.org/z/fnovozn8aCppCon0 码力 | 160 页 | 2.91 MB | 6 月前3
ThinkJS 2.0 中文文档����������� ������������������������� ThinkJS ��� think.prevent ������������������������������� Reject Promise ����� ���� think.prevent ������������������� think.defer().promise �� �� Pending Promise process.nextTick(function(){ if(xxx){ deferred.resolve(data); }else{ deferred.reject(err); } }) return deferred.promise; } JavaScript �� �� callback ������� Deferred function(){ return new Promise(function(resolve, reject){ process.nextTick(function(){ if(xxx){ resolve(data); }else{ reject(err); } }) }) } JavaScript0 码力 | 238 页 | 1.87 MB | 1 年前3
ThinkJS 2.2 Documentationif(err){ deferred.reject(err); }else{ deferred.resolve(body); } }); } To convert it to promise style, you should create an deferred object to resolve or reject in callback function think.prevent for preventing the subsequent logic to execute. This method returns a specific type of Reject Promise. think.middleware('parse_xml', async http => { let payload = await http.getPayload(); process.nextTick(function(){ if(xxx){ deferred.resolve(data); }else{ deferred.reject(err); } }) return deferred.promise; } The way using Deferred is much cleaner than the0 码力 | 156 页 | 2.62 MB | 1 年前3
ThinkJS 2.1 Documentationthink.prevent for preventing the subsequent logic to execute. This method returns a specific type of Reject Promise. In order to prevent the subsequent logic to execute, beside using the method think.prevent argument. err {Error} Error object return {Promise} reject promise Return a reject promise, and the difference between this and Promise.reject is this function will print error message automaticallly deferred.reject(err); } }) return deferred.promise; } JavaScript // the way using new Promise var fn = function(){ return new Promise(function(resolve, reject){ process.nextTick(function(){0 码力 | 148 页 | 1.69 MB | 1 年前3
ThinkJS 2.0 Documentationthink.prevent for preventing the subsequent logic to execute. This method returns a specific type of Reject Promise. In order to prevent the subsequent logic to execute, beside using the method think.prevent process.nextTick(function(){ if(xxx){ deferred.resolve(data); }else{ deferred.reject(err); } }) return deferred.promise; } JavaScript Notice: asynchronous callback operations argument. err {Error} Error object return {Promise} reject promise Return a reject promise, and the difference between this and Promise.reject is this function will print error message automaticallly0 码力 | 141 页 | 1.61 MB | 1 年前3
ThinkJS 2.2 中文文档body) => { if(err){ deferred.reject(err); }else{ deferred.resolve(body); } }); } 但这么写需要创建一个 deferred 对象,然后在回调函数里去根据 err 进行 resolve 或者 reject,写 起来有些麻烦。ThinkJS 里提供了 think.promisify 黑名单判断,如 果命中了黑名单,那么直接拒绝当前请求,不再执行后续的逻辑。 ThinkJS 提供了 think.prevent 方法用来阻止后续的逻辑执行执行,该方法是通过返回一个特定 类型的 Reject Promise 来实现的。 think.middleware('parse_xml', async http => { let payload = await http.getPayload(); deferred.reject(err); } }) return deferred.promise; } 使用 Deferred 方式比直接使用 new Promise 的方法代码更加简洁。 //直接使⽤用new Promise的⽅方式 var fn = function(){ return new Promise(function(resolve, reject){0 码力 | 277 页 | 3.61 MB | 1 年前3
ThinkJS 1.2 中文文档"after_action_name": "__after" JavaScript __before , action , __after 是通过 promise 的链式调⽤用的,如果当前操作返回⼀一个 reject promise 或者 pedding promise,那么则会阻⽌止后⾯面的执⾏行。 请求参数的值,⼀一般是在 action ⾥里通过 get(name) 或者 post(name) 来获取,如: response.statusCode !== 200){ deferred.reject(err || new Error('statusCode:' + response.statusCode)) ThinkJS 中的 Promise 使⽤用了 es6-promise 库,是个全局对象, 含有如下的⽅方法: all(array) resolve(promise | thenable | obj) reject(obj) race(array) superCls function ⽗父类 prop function | object 如果是 function,则执⾏行这个 function,并获取结果0 码力 | 104 页 | 1.29 MB | 1 年前3
Celery v5.0.1 Documentationyou really want a task to be redelivered in these scenarios you should consider enabling the task_reject_on_worker_lost setting. Warning A task that blocks indefinitely may eventually stop the worker update_state(state=states.SUCCESS, meta=timeline) raise Ignore() Reject The task may raise Reject to reject the task message using AMQPs basic_reject method. This won’t have any effect unless Task.acks_late is are redelivered to. Reject can also be used to re-queue messages, but please be very careful when using this as it can easily result in an infinite message loop. Example using reject when a task causes0 码力 | 2313 页 | 2.13 MB | 1 年前3
Celery v5.0.2 Documentationyou really want a task to be redelivered in these scenarios you should consider enabling the task_reject_on_worker_lost setting. Warning A task that blocks indefinitely may eventually stop the worker update_state(state=states.SUCCESS, meta=timeline) raise Ignore() Reject The task may raise Reject to reject the task message using AMQPs basic_reject method. This won’t have any effect unless Task.acks_late is are redelivered to. Reject can also be used to re-queue messages, but please be very careful when using this as it can easily result in an infinite message loop. Example using reject when a task causes0 码力 | 2313 页 | 2.14 MB | 1 年前3
Celery v5.0.0 Documentationyou really want a task to be redelivered in these scenarios you should consider enabling the task_reject_on_worker_lost setting. Warning A task that blocks indefinitely may eventually stop the worker update_state(state=states.SUCCESS, meta=timeline) raise Ignore() Reject The task may raise Reject to reject the task message using AMQPs basic_reject method. This won’t have any effect unless Task.acks_late is are redelivered to. Reject can also be used to re-queue messages, but please be very careful when using this as it can easily result in an infinite message loop. Example using reject when a task causes0 码力 | 2309 页 | 2.13 MB | 1 年前3
共 569 条
- 1
- 2
- 3
- 4
- 5
- 6
- 57













