Linux-Joystick
view release on metacpan or search on metacpan
Joystick.pm view on Meta::CPAN
933934935936937938939940941942943944945946947948949950951952Sets or clears non-blocking mode. Takes one
scalar
parameter, which
is treated as a boolean: a true value turns on non-blocking I/O, and
a false value turns it off. It doesn't hurt anything to attempt to set
the same mode that's already in
use
, and you can switch between the I/O
modes as many
times
as you want.
setNonblocking uses an
fcntl
() call to change the file descriptor's mode,
so it doesn
't close and reopen the device. Remember that when you'
re in
non-blocking mode, all calls to nextEvent immediately
return
. When there's
no
input, the event returned will be
undef
. Also remember not to busy-
wait
on events! If you find yourself using 99% of the CPU according to `top',
you need to restructure your code so that it works in blocking mode. If
you can
't do this (e.g. because you'
re reading from a network
socket
as
0.01) to yield the CPU so that other processes can run. An even better
to get the joystick's file handle, then
select
() on both the joystick
and network filehandles. This way, the kernel will put your process to
sleep
until
there's some input available on one stream or the other.
( run in 0.471 second using v1.01-cache-2.11-cpan-5f2e87ce722 )