cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Busy looping bug in multi_socket interface

From: Yang Tse <yangsita_at_gmail.com>
Date: Wed, 30 Apr 2008 03:35:03 +0200

2008/4/30, Jamie Lokier wrote:

> [...] changing to microseconds reduces the
> busy loop time to one microsecond, which doesn't fix the logic flaw,
> but at least hides it on all real computers.

Good point there !

Here goes an idea for the key data type...

Using a compound key of two 'long' data types would be portable safe.
The first part of the key would be the timeval 'seconds' part and the
second one the 'microseconds' one.

The 'compare' macro would be little bit more involved since it would
have four arguments.

#define compare(Kis,Kiu,Kjs,Kju) (((Kis)==(Kjs))?(Kiu)-(Kju):(Kis)-(Kjs))

And functions would simply change to something similar like:

struct Curl_tree *Curl_splay(long ks, long ku, struct Curl_tree *t);
struct Curl_tree *Curl_splayinsert(long ks, long ku, struct Curl_tree
*t, struct Curl_tree *node);
struct Curl_tree *Curl_splaygetbest(long ks, long ku, struct Curl_tree
*t, struct Curl_tree **removed);

Clear enough to grab the idea ?

-- 
-=[Yang]=-
Received on 2008-04-30