Re: gdk_threads_leave in gtk callback ?



Vladimir wrote:

Gus Koppel wrote:

There shouldn't be any additional buffer copying required just because
dealing with it moves from one thread to another. You know, all threads
have the same access to all program data.

Yes, but in my case buffers are reused to recv next packets from network, so
copying (or waiting, but this adds extra delays) is still necessarily.

Why not just use two distinct buffers with a pointer to each? Whenever
buffer 1 has received a reasonable amount of data it would be handed to
the main thread. While the main thread then processes contents of buffer
1, reception of data goes on by the other thread into buffer 2. If
buffer 2 gets full, hand that one to the main thread for further
processing and go on filling buffer 1 again, which meanwhile should have
been processed and cleared by the main thread.

Again, "to hand" and "to clear" buffers here refers to setting and
NULLing pointers only, not to memcpy(), memset() (or similar) anything.

If the 2nd buffer gets full before the first buffer has been processed
by the main thread, you should either

a) dynamically create more buffers (and pointers), or
b) dynamically enlarge the existing buffer



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]