buffering

How do I simulate a buffered peripheral device with SwingWorker?

有些话、适合烂在心里 提交于 2019-12-17 02:26:08
问题 I'm using this exercise as a pedagogical tool to help me burn in some Java GUI programming concepts. What I'm looking for is a general understanding, rather than a detailed solution to one specific problem. I expect that coding this "right" will teach me a lot about how to approach future multi-threaded problems. If this is too general for this forum, possibly it belongs in Programmers? I'm simulating a card reader. It has a GUI, allowing us to load cards into the hopper and press Start and

Does Streaming a WCF Soap Help the Client Send Using Less Memory?

六眼飞鱼酱① 提交于 2019-12-13 17:16:18
问题 I have a windows mobile application that sends data via WCF to a server. The data it sends sometimes exceeds the limit on the windows mobile device. I am wondering if streaming would help not need to hold all the data I must send in memory at once. Here is a simple example: [DataContract] public class MainContract { [DataMember] public Guid ID { get; set; } [DataMember] public List<SubContract> SubContract { get; set; } } [DataContract] public class SubContract { [DataMember] public Guid ID {

Enable buffered I/O to stdout with Intel ifort compiler

一世执手 提交于 2019-12-12 20:23:51
问题 I've read the Intel docs about enabling buffered I/O with ifort (using -assume buffered_io or FORT_BUFFERED=true ), and this works for output directly to files. However, we have large applications that are writing to stdout (e.g. write(*,*) or write(stdout,*) ), which is redirected to a file. Neither of the buffering techniques work in this case. Other than refactoring the code to write directly to files, is there a method to enable buffered I/O on stdout with ifort? This is enabled by

Reading two Characters in C#

*爱你&永不变心* 提交于 2019-12-12 14:30:10
问题 I cannot read a second character with Console.Read() method. I mean I don't get any Prompt to read the second character from Keyboard. Any help please? Also, I understand that character is by default an int but we still need to convert it to char when reading from input, is it right? The code below reads the first char but terminates with the second. public static void Main() { Console.WriteLine("The First Character?:"); char firstChar=Convert.ToChar(Console.Read()); Console.WriteLine("The

Haskell default io buffering

我的未来我决定 提交于 2019-12-12 09:33:14
问题 Yesterday i wrote a little xinetd exercise for my students: make a reverse echo program. To learn something new, i tried to implement a Haskell solution. The trivial main = forever $ interact reverse does not work. I went through this question and made a corrected version: import Control.Monad import System.IO main = forever $ interact revLines revLines = unlines . map (reverse) . lines But this corrected version also doesn't work. I read the buffering documentation and played with the

Buffering `printf` outputs between different threads in Linux

允我心安 提交于 2019-12-12 04:54:28
问题 Here is my code: #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <pthread.h> pthread_t ntid;void printids(const char *s) { printf("%s \n", s); } void * thr_fn(void *arg) { printids("new thread: "); return((void *)0); } int main(void) { pthread_create(&ntid, NULL, thr_fn, NULL); printids("main thread:"); } I'm running it on Red Hat Enterprise Linux Workstation release 6.5 . Here is my compiling command gcc -ansi -g -std=c99 -Wall -DLINUX -D_GNU_SOURCE threadid.c -o threadid

File Streamed well without buffering but gets streamed partially while buffering

依然范特西╮ 提交于 2019-12-12 01:07:37
问题 I have written a code which streams bytes from another server to my server and then I write those contents into my local file. It works fine when I use the read() method which doesn't buffer data. But when I use buffering (intention is that I believe streaming would be faster for big files) I use read(byte[]) method and it gets only partial data while streaming. I am posting the code. Can any one pls point out the mistake or concepts what I am missing. The following code works fine. (no

Setting C program to line buffer won't work

我的梦境 提交于 2019-12-11 07:36:32
问题 I'm trying to force my C program to line buffer (stdout is going to be captured by a java program), but it always seems to fully buffer instead. Here is some sample code: #include <stdio.h> #include <stdlib.h> int main(){ char c; setvbuf(stdout, NULL, _IOLBF, BUFSIZ); printf("Hello world\n"); c = getchar(); printf("got char: %c\n", c); } If I specify _IOLBF or _IOFBF, then I don't see an output until I input a char. Only if I use _IONBF will I see output before the getchar(). Shouldn't _IOLBF

Strange IOException when buffering inputStream in Java

∥☆過路亽.° 提交于 2019-12-11 05:42:34
问题 I have a weird issue regarding buffering inputStream of pdf and odt files. They are not so big, just 5 - 15 pages, but it always ends up like this java.io.IOException: Stream closed at java.io.BufferedInputStream.getInIfOpen(BufferedInputStream.java:134) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) at java.io.FilterInputStream.read

boost::asio sending data faster than receiving over TCP. Or how to disable buffering

放肆的年华 提交于 2019-12-11 02:07:24
问题 I have created a client/server program, the client starts an instance of Writer class and the server starts an instance of Reader class. Writer will then write a DATA_SIZE bytes of data asynchronously to the Reader every USLEEP mili seconds. Every successive async_write request by the Writer is done only if the "on write" handler from the previous request had been called. The problem is, If the Writer (client) is writing more data into the socket than the Reader (server) is capable of