Re: Still confused on new thread starting idle functions to update UI.



On Thu, 5 Dec 2013 03:06:59 +1100
Chris Angelico <rosuav gmail com> wrote:
[snip]
As promised, here's a simple Pike program that listens for socket
connections.
[snip]

See how much effort goes into
making sure everything's thread-safe? The same amount, because this
isn't even threaded - though it will happily handle any number of
simultaneous clients.

And to make the point for David, you can do the same in the C
GTK+/glib libraries, by abandoning threads and instead setting up an
asynchronous watch on the socket using a GIOChannel with
g_io_channel_add_watch().

However, even better than that is to use gio's high level
GSocketListener and GSocketConnection, and read on the contained
GInputStream asynchronously using g_input_stream_read_async().

Chris


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