nonblocking

Extract tar in memory and nonblocking

痞子三分冷 提交于 2019-12-12 02:05:07
问题 I need to extract a tar.gz datastream in memory. An additional limit is that I cannot block. Deflating in memory works great via zlib . Now I need the untar part. Sadly all libraries I found either block or just work with tar files. Is there any library that works similarly to zlib ? 回答1: You can try libtar. And here is an extraneous sentence to meet the required length of an SO answer. 回答2: Ok, there was no suitable library before. But now there will be, soon. Check it out here but be aware,

How to read available input without blocking on Windows

天涯浪子 提交于 2019-12-11 23:06:14
问题 On Linux, I can read available input without blocking the process: fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK ) char buf[n]; int r = fread(buf, 1, n, stdin); if (r == 0){ printf("nothing\n"); } else { printf("read: "); fwrite(buf, 1, r, stdout); printf("\n"); } The input origin can be anything, such as a file, a terminal or a pipe. How can I do it on Windows XP? Thanks. 回答1: Why not read the input from a second thread? Depending on your situation, it might be a

Can I lock and unlock a fifo (named pipe) in C?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 19:41:03
问题 I have two progress, p1 and p2 , and a named pipe var for ipc between 2 progress. I want to lock var 's rw for p2 when p1 writes, and unlock var when p1 finished write. ps: I using select for nonblocking, so p2 will get readable when p1 put anything to var .Can I let var become readable when p1 finish write? 回答1: You could use signals (e.g. SIGUSR1 ). The writer makes it pipe non-blocking (so it won't block when the pipe becomes full), writes until it can't write anymore, then send the signal

Boost asio non-blocking IO without callbacks

蓝咒 提交于 2019-12-11 13:37:37
问题 Is it possible to use Boost's asio to do non-blocking IO without using async callbacks? I.e. equivalent to the O_NONBLOCK socket option. I basically want this function: template<typename SyncWriteStream, typename ConstBufferSequence> std::size_t write_nonblock( SyncWriteStream & s, const ConstBufferSequence & buffers); This function will write as many bytes as it can and return immediately. It may write 0 bytes. Is it possible? 回答1: Yes, using the non_blocking() method to put the socket into

Non blocking input C

一个人想着一个人 提交于 2019-12-11 12:18:47
问题 I'm trying to create a program where the user is asked a question and has a few seconds to answer the question, or else the program stops input. Now my problem is I'm unable to get my program not to block input. I am able to input data, but when I don't and the timer runs out it keeps asking for input. I'm running on Windows and use Code::Blocks in case it's important. If someone could explain to me what I'm doing wrong, it would be appreciated. #include <stdio.h> #include <stdlib.h> #include

Why does Tornado spend time in socket.send(data)?

白昼怎懂夜的黑 提交于 2019-12-11 12:06:32
问题 I'm looking at profiles for my Tornado TCP application and I'm finding that the thread running the event loop spends about 20% time in tornado/iostream.py::write_to_fd in the line self.socket.send(data) and about 15% time in tornado/iostream.py::read_from_fd in the line self.socket.recv_into(buf) . Given that these are non-blocking sockets, why does this take any time at all? What are common situations for this to take time and are there any common optimizations I can do to my application to

How to do a non-blocking read on a non-socket fd

隐身守侯 提交于 2019-12-11 12:05:29
问题 Is there a way to do a single read() in non-blocking mode on a pipe/terminal/etc, the way I can do it on a socket with recv(MSG_DONTWAIT) ? The reason I need that is because I cannot find any guarantee that a read() on a file-descriptor returned as ready for reading by select() or poll() will not block. I know can make the file descriptor non-blocking with fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) but this will change the mode on that file descriptor globally, not just in the

Go non-blocking channel send, test-for-failure before attempting to send?

这一生的挚爱 提交于 2019-12-11 07:13:28
问题 Is there a way to test for failure of a go channel send without actually attempting the send? The standard non-blocking send is like so: msg := "hi" select { case messages <- msg: fmt.Println("sent message", msg) default: fmt.Println("no message sent") } The problem is that I need to have "msg" ready to send in order to test the channel. I would like to test to see if a send will fail in a way that does not require having "msg" ready for sending. 回答1: That would do no good in the general case

Are jQuery fadeIn(), animation() functions non-blocking?

和自甴很熟 提交于 2019-12-11 05:07:53
问题 I have a page which issues several ajax queries in $('document').ready() . I want to use fadeIn() or animation() to display some information for a few seconds after received the first ajax call. Will the following js/ajax calls be blocked during the animation playing? Or should I use setTimeout to delay the animation a second so the ajax calls can be started asynchronously? Edit: My code will look like this. Will the others ajax calls be blocked for 5 seconds? $.ajax({..., success: function

Janrain RPXnow (Engage) (https://rpxnow.com/) bypasses popup-blockers… how?

删除回忆录丶 提交于 2019-12-11 04:57:28
问题 Basically I need to open a login window in a popup, so that it doesn't get blocked by popup blocker. Similar to what Janrain does in it's RPXnow solution. How do they do that? 回答1: Most pop-up blockers allow pop-ups that were triggered by a user action, e.g. clicking on one of the login links on the page you linked to. So if you tie your login popup to a login button that the user has to click to open it then it ought to get past the blockers OK. (or am I missing the point - were there other