Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Oct 2004 00:25:30 +0400 (MSD)
From:      Igor Sysoev <is@rambler-co.ru>
To:        "Ronald F. Guilmette" <rfg@monkeys.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: aio_connect ? 
Message-ID:  <20041023002300.I91215@is.park.rambler.ru>
In-Reply-To: <93418.1098386003@monkeys.com>
References:  <93418.1098386003@monkeys.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 21 Oct 2004, Ronald F. Guilmette wrote:

> >I believe if you want to build a more maintainable, more adaptable,
> >more modularized program then you should avoid two things - the threads and
> >the signals. If you like to use a callback behaviour of the signals you could
> >easy implement it without any signal.
>
> OK.  I'll bite.  How?

I'm sure you know it.  Sorry, English is not my native language so I may
tell you only shortly.

You can use two notification models.  First is the socket readiness
for operations, second is the operation completeness.
In the first model you use usual read()/write() operations and learn
readiness using select()/poll()/kevent().
In the second model you use aio_read()/aio_write() operations and learn
about their completeness using aio_suspend()/aio_waitcomplete()/kevent().

After you have got the notifications you would call your callback handlers
as well as the kernel would call your signal handlers.

The difference between your code and kernel is that your code always
calls handlers in the well known places that allows to avoid the various race
conditions.  The kernel may call the signal handler any time if the signal
is not blocked.


Igor Sysoev
http://sysoev.ru/en/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041023002300.I91215>