buffering

Piping sometimes does not lead to immediate output

落花浮王杯 提交于 2019-12-20 07:21:33
问题 I observed a few times now that A | B | C may not lead to immediate output, although A is constantly producing output. I have no idea how this even may be possible. From my understanding all three processes ought to be working on the same time, putting their output into the next pipe (or stdout) and taking from the previous pipe when they are finished with one step. Here's an example where I am currently experiencing that: tcpflow -ec -i any port 8340 | tee second.flow | grep -i "\(<

Close connection in PHP but keep executing script

醉酒当歌 提交于 2019-12-19 09:09:16
问题 Anyone know how to close the connection (besides just flush() ?), but keep executing some code afterwards. I don't want the client to see the long process that may occur after the page is done. 回答1: You might want to look at pcntl_fork() -- it allows you to fork your current script and run it in a separate thread. I used it in a project where a user uploaded a file and then the script performed various operations on it, including communicating with a third-party server, which could take a

c++ std::ofstream flush() but not close()

廉价感情. 提交于 2019-12-18 12:59:09
问题 I'm on MacOSX. In the logger part of my application, I'm dumping data to a file. suppose I have a globally declared std::ofstream outFile("log"); and in my logging code I have: outFile << "......." ; outFile.flush(); Now, suppose my code crashes after the flush() happens; Is the stuff written to outFile before the flush() guaranteed to be written to disk (note that I don't call a close() ). Thanks! 回答1: From the C++ runtime's point of view, it should have been written to disk. From an OS

Reduce video buffering

≡放荡痞女 提交于 2019-12-18 12:42:14
问题 I'm playing video on Android using media player via RTSP. The player takes about 12s to buffer before it starts playing. Anyone know how I can convince the player to buffer less? I have full control over the RTSP server and the SDP it returns. 回答1: As per usual, as soon as I decide I should ask a question I work out the answer. I have a line "b=AS:91" in my SDP. If I reduce the number the amount of buffering decreases - so b=AS:2 gives about 4 or 5s buffering. 来源: https://stackoverflow.com

Why use endl when I can use a newline character? [duplicate]

懵懂的女人 提交于 2019-12-18 09:59:45
问题 This question already has answers here : C++: “std::endl” vs “\n” (13 answers) Closed 2 years ago . Is there a reason to use endl with cout when I can just use \n ? My C++ book says to use endl, but I don't see why. Is \n not supported as widely as endl , or am I missing something? 回答1: endl appends '\n' to the stream and calls flush() on the stream. So cout << x << endl; is equivalent to cout << x << '\n'; cout.flush(); A stream may use an internal buffer which gets actually streamed when

Perl, disable buffering input

徘徊边缘 提交于 2019-12-18 08:17:10
问题 There is a file: :~$ cat fff qwerty asdf qwerty zxcvb There is a script: :~$ cat 1.pl #!/usr/bin/perl print <STDIN> The command works as expected: :~$ cat fff | perl -e 'system("./1.pl")' qwerty asdf qwerty zxcvb But this command will not work as expected: the first <STDIN> reads all the data, not a single line. How to disable buffering for <STDIN>? :~$ cat fff | perl -e '$_ = <STDIN>; system("./1.pl")' :~$ 回答1: There are two Perl processes here - the first that assigns $_ = <STDIN> and calls

Why doesn't print output anything on each iteration of a loop when I use sleep?

此生再无相见时 提交于 2019-12-17 12:15:23
问题 Today in my college a teacher asked me a question. He wrote this code on the paper and said "What will be the output of this code?" use warnings; for (1 .. 20) { print "."; } I found it easy and said that it will loop 20 times and at each iteration it will print a dot (.) and hence total 20 dots will be the output. He said you are right and then he made some changes in the code. The code was: use warnings; for (1 .. 20) { print "."; sleep 1; } He said the what will be the output now? I didn't

Rx IObservable buffering to smooth out bursts of events

别说谁变了你拦得住时间么 提交于 2019-12-17 10:33:14
问题 I have an Observable sequence that produces events in rapid bursts (ie: five events one right after another, then a long delay, then another quick burst of events, etc.). I want to smooth out these bursts by inserting a short delay between events. Imagine the following diagram as an example: Raw: --oooo--------------ooooo-----oo----------------ooo| Buffered: --o--o--o--o--------o--o--o--o--o--o--o---------o--o--o| My current approach is to generate a metronome-like timer via Observable

Buffered RandomAccessFile java

不羁的心 提交于 2019-12-17 08:53:17
问题 RandomAccessFile is quite slow for random access to a file. You often read about implementing a buffered layer over it, but code doing this isn't possible to find online. So my question is: would you guys who know any opensource implementation of this class share a pointer or share your own implementation? It would be nice if this question would turn out as a collection of useful links and code about this problem, which I'm sure, is shared by many and never addressed properly by SUN. Please,

HTML5 Video buffered attribute features

本小妞迷上赌 提交于 2019-12-17 08:30:25
问题 I am designing a custom HTML5 video player. Thus, it will have its own custom slider to mimic the video progress, so I need to understand the entire buffering shebang of a HTML5 video. I came across this article: Video Buffering. It says that the buffered object consists of several time ranges in linear order of start time. But I couldn't find out the following: Say the video starts. It continues upto 1:45 on its own (occasionally stalling perhaps, waiting for further data), after which I