Re:Why threads vs events is a nonsensical question.
by jrockway on Sunday August 21, 2011 @01:29AM
(#2908583)
No, threads tend to be:
while( connection = accept_connection ){
in_thread_run(handle_connection, connection)
}
Re:Why threads vs events is a nonsensical question.
by nitrogen on Sunday August 21, 2011 @06:03AM
(#2908892)
That is event-driven code. A typical accept_connection only returns after receiving a connection event. The I/O code in handle_connection blocks until the event that data can be read/written. The event handling just happens in the OS instead of in userspace with poll/select/etc.
Re:Why threads vs events is a nonsensical question.
by FooBarWidget on Sunday August 21, 2011 @08:35AM
(#2909077)
Eh? If you reason that way then all I/O code is evented and that makes the discussion meaningless. Event-styled code doesn't have anything that blocks except the event loop I/O multiplexer and everything returns to the event loop ASAP.
This being said, event-driven as a design choice has much to recommend it.