callback

Asynchronous Callback in NSOperation inside of NSOperationQueue is never called

荒凉一梦 提交于 2020-01-06 19:30:47
问题 I need to chain together several NSOperation s that do network calls in one NSOperationQueue and then wait for all to be completed. I'm adding all of the NSOperation s to my NSOperationQueue and then call operationQueue.waitUntilAllOperationsAreFinished() . This works, but it waits indefinitely, as the callbacks in the NSOperations , that set the operation's state to 'finished', get never called. I'm using the following NSOperation subclass: class ConcurrentOperation: NSOperation { enum State

Promisifying Callbacks in Node.js [duplicate]

走远了吗. 提交于 2020-01-06 18:36:11
问题 This question already has answers here : How do I convert an existing callback API to promises? (20 answers) Closed 2 years ago . I have this node js app working with several callback functions which I am trying to promisify to no avail. Its getting to the point where I dont know if it is even possible. If you can help me promisify the code below I'll probably be able to do the rest of it: var i2c_htu21d = require('htu21d-i2c'); var htu21df = new i2c_htu21d(); htu21df.readTemperature(function

Promisifying Callbacks in Node.js [duplicate]

自作多情 提交于 2020-01-06 18:36:11
问题 This question already has answers here : How do I convert an existing callback API to promises? (20 answers) Closed 2 years ago . I have this node js app working with several callback functions which I am trying to promisify to no avail. Its getting to the point where I dont know if it is even possible. If you can help me promisify the code below I'll probably be able to do the rest of it: var i2c_htu21d = require('htu21d-i2c'); var htu21df = new i2c_htu21d(); htu21df.readTemperature(function

京东商品自动下单

三世轮回 提交于 2020-01-06 14:56:43
在现在,商家一年不卖货,双11卖出一年的货是大家都知道的事实了,总得来说调一调蚊子腿的价格,聊胜于无,但是也会有些神价格会出现,这时候买到就是赚到 本来是想趁着双11组台电脑,买个 Z370 的板U套装,没想到京东的 8700k 一直是无货的状态,这几天有货了,价格涨到了3999,简直不能忍,看了下板U套装比较划算,但是有些板U套装是不支持自动下单的,所以 gayhub 搜搜看有没有爬虫可以监听到货自动下单的,正好有了这哥们的 jd-autobuy Python 脚本,还有 Go 的,看了下接口已经很齐全了,来个 node 版本的助助兴 这次用到的 http 库是 axios ,支持客户端和服务端,总得来说语法还是很简洁的,在这之前还有个 superagent 库,看了下也差不多,只不过 superagent 在 response 上多处理了下 因为在 vue 中使用了 axios,这次想试试服务端的能力咋样,还是一如既往的好,滋次一波 先写个 request header ,毕竟是服务端,没有浏览器帮你处理 User-Agent,所以自己去浏览器请求下然后把 header 拿到 const defaultInfo = { header: { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0)

Reading multiple files in parallel and writing the data in new files accordingly node.js

懵懂的女人 提交于 2020-01-06 12:48:53
问题 I'm trying to handle a asynchronous action that read multiple files from a folder at a same time and writes new ones in a different folder. The files that I read are by pair. One file is the data template and the other one is about the data. According to the template, we process the data from the related data file. All the information that I got from the both files are inserted into an object that I need to write in JSON into a new file . The code below works perfectly if there are only one

Reading multiple files in parallel and writing the data in new files accordingly node.js

萝らか妹 提交于 2020-01-06 12:47:55
问题 I'm trying to handle a asynchronous action that read multiple files from a folder at a same time and writes new ones in a different folder. The files that I read are by pair. One file is the data template and the other one is about the data. According to the template, we process the data from the related data file. All the information that I got from the both files are inserted into an object that I need to write in JSON into a new file . The code below works perfectly if there are only one

c++11 lambda as callback of ReadFileEx

蓝咒 提交于 2020-01-06 12:21:04
问题 Here is the code. #include <windows.h> #include <stdio.h> #include <tchar.h> int _tmain(int argc, _TCHAR* argv[]) { auto f = CreateFile(L"file.txt", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); struct overlapped_buffer { OVERLAPPED o; char b[64]; }; overlapped_buffer ob = {}; ReadFileEx(f, ob.b, sizeof(ob.b), &ob.o, [] (DWORD e, DWORD c, OVERLAPPED * o) { if( ERROR_SUCCESS == e ) printf("Error"); else { auto ob = reinterpret_cast<overlapped_buffer *>

jQuery animation on window load on an infinite loop?

被刻印的时光 ゝ 提交于 2020-01-06 08:57:31
问题 I need a hand making this code below working. I've had it working so that when the user hovers over the image it animates up, then down when losing focus, but now I want it to run on window load on an infinite loop. $(document).ready(function(){ $(window).load(function(){ $('.navImage').animate({top:'-=13'}, 700) }, function(){ $('.navImage').animate({top:'+=13'}, 700); }); }); At the moment it's only animating 13pixels up, not down, and obviously the animation doesn't currently loop. Do I

MediaCodec Async Callback is not occurring if other thread has blocking wait

北城余情 提交于 2020-01-06 08:57:29
问题 I am using MediaCodec OnAsyncInputAvailable and OnAsyncOutputAvailable callbacks introduced in API 28. void OnAsyncInputAvailable( AMediaCodec *codec, void *userdata, int32_t index) { CallbackData* callbackData = (CallbackData *) (userdata); callbackData->addInputBufferId(index); } void OnAsyncOutputAvailable( AMediaCodec *codec, void *userdata, int32_t index, AMediaCodecBufferInfo *bufferInfo) { CallbackData* callbackData = (CallbackData *) (userdata); callbackData->addOutputBuffer(index,

How to execute a javascript/jquery function only after the completion of another function?

好久不见. 提交于 2020-01-06 07:02:35
问题 I know this is a simple question, but I don't really know how to do it. I'm executing two functions in my code, 'luxboxEngine' and 'fitToScreen', the latter of which requires the completion of the former. How do I tell 'fitToScreen' to only execute after 'luxboxEngine' has completed? Right now I have this, which gets the desired results: luxboxEngine(self); setTimeout(fitToScreen, 1000); ...But I know that's not a good solution. I've read about callback functions, but I'm afraid I don't