buffering

Using Core Graphics/ Cocoa, can you draw to a bitmap context from a background thread?

南笙酒味 提交于 2019-11-29 18:34:22
问题 I'm drawing offscreen to a CGContext created using CGBitmapContextCreate , then later generating a CGImage from it with CGBitmapContextCreateImage and drawing that onto my view in drawRect (I'm also drawing some other stuff on top of that - this is an exercise in isolating different levels of variability and complexity). This all works fine when it's all running on the main thread. However one of the motivations for splitting this out this way was so that the offscreen part could be run on a

Why fprintf doesn't write directly into the file unless fflush() is used?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 18:14:27
I have written a daemon that writes a value in a file. What I have observed is that when I keep writing on a file, there is nothing visible in the file. in other hand, If I use fflush() method then the characters are visible in the file. Why fflush() makes a difference? Because it's buffered . That means all writes are stored in a buffer in memory until the buffer is flushed. For printf and friends it's when it has either a newline, or you explicitly call fflush , or of course if the buffer becomes full. By default, stdio is fully buffered, unless it's writing to a terminal, in which case it's

Perl, disable buffering input

橙三吉。 提交于 2019-11-29 13:52:49
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")' :~$ There are two Perl processes here - the first that assigns $_ = <STDIN> and calls system , and the second that does print <STDIN> Although only the first line of the stream is read into $_

How to avoid Python fileinput buffering [duplicate]

↘锁芯ラ 提交于 2019-11-29 13:47:24
Possible Duplicate: Setting smaller buffer size for sys.stdin? I have a Python (2.4/2.7) script using fileinput to read from standard input or from files. It's easy to use, and works well except for one case: tail -f log | filter.py The problem is that my script buffers its input, whereas (at least in this case) I want to see its output right away. This seems to stem from the fact that fileinput uses readlines() to grab up to its bufsize worth of bytes before it does anything. I tried using a bufsize of 1 and it didn't seem to help (which was somewhat surprising). I did find that I can write

Python in raw mode stdin print adds spaces

北战南征 提交于 2019-11-29 06:47:39
I needed to switch the standard input to non-buffered mode in Python, so that I can read single characters off it. I managed to get it working, but now the standard output is broken: somehow it seems like after the newline character, some space characters are emitted, zero on the first line, 3 on the second, 6 on the third, etc, like this: ASD ASD ASD Operating system is Ubuntu Linux 12.04, 64-bit edition, Python version is 3.2.3. How can I rid myself from this behavior? Below is the code I've used: import sys import tty import termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr

Turn off buffering

岁酱吖の 提交于 2019-11-29 03:45:39
Where is the buffer in this following ... and how do I turn it off? I am writing out to stdout in a python program like so: for line in sys.stdin: print line There is some buffering going on here: tail -f data.txt | grep -e APL | python -u Interpret.py I tried the following to shake off possible buffering ... with no luck: as above using the -u flag with python invocation calling sys.stdout.flush() after each sys.stdout.write() call ... all of these create a buffered stream with python waiting something like a minute to print out the first few lines. used the following modified command: stdbuf

Why does printf() not print anything before sleep()?

五迷三道 提交于 2019-11-28 20:36:49
I'm just learning C with Kernighan and Ritchie's book; I'm in the basics of the fourth chapter (functions stuff). The other day I became curious about the sleep() function, so tried to use it like this: #include <stdio.h> #include <unistd.h> int main(void) { printf(" I like cows."); sleep(5); return 0; } The problem is the output of the program, it looks like it does the sleep() first and then the printf() , in other words, it waits five seconds and then prints the string. So I thought, maybe the program gets to sleep() so fast that it doesn't let printf() have his work done like I want, that

Response Buffer Limit Exceeded

陌路散爱 提交于 2019-11-28 20:06:14
I am running a simple query to get data out of my database & display them. I'm getting an error that says Response Buffer Limit Exceeded . Error is : Response object error 'ASP 0251 : 80004005' Response Buffer Limit Exceeded /abc/test_maintenanceDetail.asp, line 0 Execution of the ASP page caused the Response Buffer to exceed its configured limit. I have also tried Response.flush in my loop and also use response.buffer = false in my top of the page, but still I am not getting any data. My database contains 5600 records for that, Please give me some steps or code to solve the issue. I know this

Buffered reading from stdin using fread in C

99封情书 提交于 2019-11-28 19:23:46
问题 I am trying to efficiently read from the stdin by using setvbuf in `_IOFBF~ mode. I am new to buffering. I am looking for working examples. The input begins with two integers ( n , k ). The next n lines of input contain 1 integer. The aim is to print how many integers are divisible by k . #define BUFSIZE 32 int main(){ int n, k, tmp, ans=0, i, j; char buf[BUFSIZE+1] = {'0'}; setvbuf(stdin, (char*)NULL, _IONBF, 0); scanf("%d%d\n", &n, &k); while(n>0 && fread(buf, (size_t)1, (size_t)BUFSIZE,

Android - How to tell when MediaPlayer is buffering

纵饮孤独 提交于 2019-11-28 18:41:02
问题 I've got to be missing something obvious here, but I can't seem to find anything to allow me to determine when MediaPlayer is buffering audio. I'm streaming internet audio and I want to display a buffering indicator, but nothing I've tried allows me to know when MediaPlayer interrupts the audio to buffer, so I can't properly display a buffering indicator. Any clues? 回答1: @Daniel, per your comment on @JRL's answer, you could probably get this working by spinning up a thread and waiting for a