On Aug 23, 2013, at 3:58 AM, Igor Galić <[email protected]> wrote:

> 
> 
> ----- Original Message -----
>> On Fri, Aug 23, 2013 at 12:17 AM, James Peach <[email protected]> wrote:
>> 
>>> On Aug 22, 2013, at 5:01 AM, [email protected] wrote:
>>> 
[snip]
>> 
>> In some scenario, the upper layer store absolute time before calling
>> timedwait, such as ProtectedQueue.
>> 
>> By using int type, the upper layer can calculate timeout more simply:
>> 
>>         timeout = now - abstime;
>> 
>> The upper layer needn't to care about whether the timeout is < 0. We will
>> check it automatically inside the timedwait() function. I think use int
>> type could be more user friendly.
> 
> maybe int64 is a better choice? 

int64 would be a bit overkill for a timeout I think. I can live with int, 
though I do think that unsigned is a better choice. The reason is that when you 
do a timed what, you almost never do an absolute timeout; you do something like 
lock.timedwait(10), so taking a signed typed allows ambiguity where none is 
needed.

The meaning of lock.timedwait(-1) in this case will be the same as 
lock.timedwait(0), however I agree with Yunkai that using a signed type could 
be more robust against signed arithmetic errors.

J

Reply via email to