Daniel Fort <naquad / gmail.com> wrote:
> hi.
> 
> I'm writing tcp server and I want to know:
> 
> 1. how can I block thread until some event will occur w/o overhead?
> (i.e. not timer, but something like semaphore);

A Conditionariable, IO.select (which you already knew :),
or a blocking read on any socket or pipe.

> 2. how can I interrupt IO::select() call from main thread?

Create a socketpair or pipe and and write to it from the main thread.
It's also useful with the self-pipe trick[1]

If you're stuck on a platform without UNIX sockets or pipes, you can
also connect to your main TCPServer (or another private one) to
wakeup from select.

[1] http://cr.yp.to/docs/selfpipe.html

-- 
Eric Wong