MsgReceive & Select

Hi,

I have an interesting design question. I have a process that needs to act
on both console input/key presses and messages from other processes. Right
now I achieve this by creating a channel for receiving messages via
MsgReceive and creating a special-purpose thread whose sole purpose is to
read STDIN. My process blocks on MsgReceive and the special-purpose thread
uses MsgSend to send each keypress. Other processes also use MsgSend to
send messages that my process must act on. This kind of bothers me; there
is not that much keyboard activity, but it seems like a lot of overhead to
be sending every stinking key press in message via MsgSend. So, I’m looking
for an alternative. It would be great if I could use “select” and wait on
the read to STDIN while also waiting on a message from MsgReceive, but, of
course, “select” only works with descriptors, not channels. Any suggestions
will be appreciated.

Thanks,

Halden

Halden wrote:

Hi,

I have an interesting design question. I have a process that needs to act
on both console input/key presses and messages from other processes. Right
now I achieve this by creating a channel for receiving messages via
MsgReceive and creating a special-purpose thread whose sole purpose is to
read STDIN. My process blocks on MsgReceive and the special-purpose thread
uses MsgSend to send each keypress. Other processes also use MsgSend to
send messages that my process must act on. This kind of bothers me; there
is not that much keyboard activity, but it seems like a lot of overhead to
be sending every stinking key press in message via MsgSend. So, I’m looking
for an alternative. It would be great if I could use “select” and wait on
the read to STDIN while also waiting on a message from MsgReceive, but, of
course, “select” only works with descriptors, not channels. Any suggestions
will be appreciated.

Thanks,

Halden

If there’s only one keyboard, no way can this become a significant
overhead item.

John Nagle

“John Nagle” <nagle@downside.com> wrote in message
news:d2qddb$nvg$1@inn.qnx.com

Halden wrote:

Hi,

I have an interesting design question. I have a process that needs to
act on both console input/key presses and messages from other processes.
Right now I achieve this by creating a channel for receiving messages via
MsgReceive and creating a special-purpose thread whose sole purpose is to
read STDIN. My process blocks on MsgReceive and the special-purpose
thread uses MsgSend to send each keypress. Other processes also use
MsgSend to send messages that my process must act on. This kind of
bothers me; there is not that much keyboard activity, but it seems like a
lot of overhead to be sending every stinking key press in message via
MsgSend. So, I’m looking for an alternative. It would be great if I
could use “select” and wait on the read to STDIN while also waiting on a
message from MsgReceive, but, of course, “select” only works with
descriptors, not channels. Any suggestions will be appreciated.

Look at ionotif()y. You can request a notification event when keypress are
available.

Thanks,

Halden

If there’s only one keyboard, no way can this become a significant
overhead item.

John Nagle