LWN.net Logo

Thread-based or event-based?

Thread-based or event-based?

Posted Mar 1, 2007 18:30 UTC (Thu) by zooko (subscriber, #2589)
In reply to: Thread-based or event-based? by bronson
Parent article: Thread-based or event-based?

I think you are right inasmuch as you are writing in C code. If you are writing in Python it is rather easier to write your event-based code. Certainly when we rewrote Mojo Nation (a open source peer-to-peer filesharing app) from one-thread-per-connection to event-based it was easier to understand and debug afterward than before. (By the way, that's the origin of BitTorrent's use of event-based -- Bram worked at Mojo Nation and re-used the event-based architecture that we developed there when he wrote BitTorrent.)

If you are writing in Twisted Python it is easier still, and if you are writing in E it is easier still.

C++ and Java fall right between C and Python in terms of the difficulty of doing event-based -- I have written multithreaded code and event-based code in each of them.

By the way, almost all GUI toolkits use the event-based paradigm, so many programmers are already familiar with the paradigm in at least one domain.

Regards,

Zooko


(Log in to post comments)

Thread-based or event-based?

Posted Mar 1, 2007 20:38 UTC (Thu) by bronson (subscriber, #4806) [Link]

What did you use to do event-based in C++? Did you like it?

It seems like many modern GUI toolkits are using closures and continuations to hide the event loop. So, while many programmers are familiar with it, I'm not sure they really like it. :)

Thread-based or event-based?

Posted Mar 12, 2007 17:19 UTC (Mon) by zooko (subscriber, #2589) [Link]

I did event-based code in C++ in a few ways -- non-blocking I/O with my own event framework atop it, various GUI toolkits, and in a sense also using DEC Message Queue middleware.

It was satisfying enough. Certainly the freedom from deadlock was worth it.

Thread-based or event-based?

Posted Mar 2, 2007 17:34 UTC (Fri) by krasic (subscriber, #4782) [Link]

I know a bit about twisted, but I don't know about "E". Could someone give a reference or pointer?

Thread-based or event-based?

Posted Mar 2, 2007 18:06 UTC (Fri) by markh (subscriber, #33984) [Link]

> I know a bit about twisted, but I don't know about "E". Could someone
> give a reference or pointer?

http://erights.org/

Thread-based or event-based?

Posted Mar 2, 2007 18:17 UTC (Fri) by shane (subscriber, #3335) [Link]

If you are writing in Python it is rather easier to write your event-based code.

Of course, it's also easier to write your threaded code.:)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds