[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Polling sockets - home-made ALT

bmc wrote:

I find that windoze seems to reschedule in 200ms intervals - too long! I do (pseudo-code):

   while( x.available() == none ) { Thread.sleep( N ); }

where N is a small integer (ms in Java)  (1 if I'm really needing performance). It, obviously takes some processor time - but responds MUCH more quickly than a blocking call (on windoze, at least).

This would also give you a repeatecd wake-up to check a flag by way of interrupt.

This works very well:

while( x.available() == none && running ) { Thread.sleep( N ); } if (running)
   { x.read(); }

The value of N seems not very sensitive on Windoze (my 2.4GHz pc), even with N=1 it seems not to hammer the CPU even the slightest. Now I'll try it on my Solaris box and check that N=1 is still OK.

Thanks Barry and all.
Rick :-)

Registered Office: Roke Manor Research Ltd, Siemens House, Oldbury, Bracknell, 
Berkshire. RG12 8FZ

The information contained in this e-mail and any attachments is confidential to Roke 
Manor Research Ltd and must not be passed to any third party without permission. This 
communication is for information only and shall not create or change any contractual