buffering

C# .NET - Buffer messages w/Timer

元气小坏坏 提交于 2019-12-02 05:46:25
I need to implement a message buffering system that is also timed based. What I need to do is store instances of my class and then send them forward either when I reach 100 instances or when 1 minute has passed. Basically: List<Message> messages; public void GotNewMessage(Message msg) { messages.add(msg); if (messages.count() == 100 || timer.elapsed(1 minute)) { SendMessages(messages); messages.clear() } } I just can't seem to figure out how to implement this without an excessive use of locks which will slow down the process considerably. Does anyone know of a good way to implement such a

What is IO Stream Buffering?

二次信任 提交于 2019-12-02 04:32:29
I am unable to find the underlying concept of IO Stream Buffering and what does it mean. Any tutorials and links will be helpful. Buffering is a fundamental part of software that handles input and output. The buffer holds data that is in between the software interface and the hardware interface, since hardware and software run at different speeds. A component which produces data can put it into a buffer, and later the buffer is "flushed" by sending the collected data to the next component. Likewise the other component may be "waiting on the buffer" until a complete piece of data, or enough

Java page flipping not supported on Mac OS?

社会主义新天地 提交于 2019-12-02 02:14:20
I'm hoping someone happens to have stumbled upon the following issue before. My Java application has graphics performance issues on Mac, so I made a simple test application (code below). When I run this on Windows, the console tells me: GraphicsConfiguration flipping? true BufferStrategy flipping? true When I run the exact same code on Mac OS, I get: GraphicsConfiguration flipping? true BufferStrategy flipping? false Does this mean that on Mac OS, page flipping is simply not supported in a windowed application? Are there any tricks to make page flipping work on Mac OS without going full screen

std::ifstream buffer caching

时间秒杀一切 提交于 2019-12-01 16:06:57
In my application I'm trying to merge sorted files (keeping them sorted of course), so I have to iterate through each element in both files to write the minimal to the third one. This works pretty much slow on big files, as far as I don't see any other choice (the iteration has to be done) I'm trying to optimize file loading. I can use some amount of RAM, which I can use for buffering. I mean instead of reading 4 bytes from both files every time I can read once something like 100Mb and work with that buffer after that, until there will be no element in buffer, then I'll refill the buffer again

handling central data buffer for many processes in C++

时间秒杀一切 提交于 2019-12-01 08:31:11
I ran into the following problem and cannot decide how to proceed: I have a class, Reader , getting a chunk of data every 1/T seconds (actually the data is from video frames, 30 frames per second). The chunks are to be passed to several objects, Detectors that process the chunks and output a decision. However, the number of chunks that each detector needs to read before making a decision varies, e.g. some may need only one chunk, some 51. I am thinking of having a data buffer where Reader places the read data chunks, implementing publish/subscriber to register each Detector and sending it a

Close connection in PHP but keep executing script

流过昼夜 提交于 2019-12-01 07:32:20
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. Jhong 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 long time. After the initial upload, the script forked and displayed the next page to the user, and the

How to speed Haskell IO with buffering?

自作多情 提交于 2019-12-01 06:20:54
I read about IO buffering in the "Real World Haskell" (ch. 7, p. 189), and tried to test, how different buffering size affects the performance. import System.IO import Data.Time.Clock import Data.Char(toUpper) main :: IO () main = do hInp <- openFile "bigFile.txt" ReadMode let bufferSize = truncate $ 2**10 hSetBuffering hInp (BlockBuffering (Just bufferSize)) bufferMode <- hGetBuffering hInp putStrLn $ "Current buffering mode: " ++ (show bufferMode) startTime <- getCurrentTime inp <- hGetContents hInp writeFile "processed.txt" (map toUpper inp) hClose hInp finishTime <- getCurrentTime print $

Problems with sys.stdout.write() with time.sleep() in a function

一个人想着一个人 提交于 2019-12-01 05:46:32
What I wanted is printing out 5 dots that a dot printed per a second using time.sleep(), but the result was 5 dots were printed at once after 5 seconds delay. Tried both print and sys.stdout.write, same result. Thanks for any advices. import time import sys def wait_for(n): """Wait for {n} seconds. {n} should be an integer greater than 0.""" if not isinstance(n, int): print 'n in wait_for(n) should be an integer.' return elif n < 1: print 'n in wait_for(n) should be greater than 0.' return for i in range(0, n): sys.stdout.write('.') time.sleep(1) sys.stdout.write('\n') def main(): wait_for(5)

How to speed Haskell IO with buffering?

情到浓时终转凉″ 提交于 2019-12-01 04:12:50
问题 I read about IO buffering in the "Real World Haskell" (ch. 7, p. 189), and tried to test, how different buffering size affects the performance. import System.IO import Data.Time.Clock import Data.Char(toUpper) main :: IO () main = do hInp <- openFile "bigFile.txt" ReadMode let bufferSize = truncate $ 2**10 hSetBuffering hInp (BlockBuffering (Just bufferSize)) bufferMode <- hGetBuffering hInp putStrLn $ "Current buffering mode: " ++ (show bufferMode) startTime <- getCurrentTime inp <-

How to detect when video is buffering?

↘锁芯ラ 提交于 2019-12-01 00:42:59
my question today deals with Flash AS3 video buffering. (Streaming or Progressive) I want to be able to detect when the video is being buffered, so I can display some sort of animation letting the user know to wait just a little longer. Currently my video will start up, hold on frame 1 for 3-4 secs then play. Kinda giving the impression that the video is paused or broken :( Update Thanks to iandisme I believe I'm faced in the right direction now. NetStatusEvent from livedocs . It seems to me that the key status to be working in is "NetStream.Buffer.Empty" so I added some code in there to see