tech-kern archive

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

Re: Locking interface in "libprop" implementation



>       Hello,
> 
> the locking primitives in "libprop" are currently used like this:
> 
>       _PROP_RWLOCK_RDLOCK(pd->pd_rwlock);
>       _PROP_RWLOCK_WRLOCK(pd->pd_rwlock);
>       _PROP_RWLOCK_UNLOCK(pd->pd_rwlock);
> 
>       _PROP_RWLOCK_RDLOCK(pa->pa_rwlock);
>       _PROP_RWLOCK_UNLOCK(pa->pa_rwlock);
>       _PROP_RWLOCK_WRLOCK(pa->pa_rwlock);
> 
> This interface is IMHO a bit messy because in the case of stand alone
> binaries neither "pd_rwlock" nor "pw_rwlock" actually exist. Is there
> a reason why the interface doesn't look like this?
> 
>       _PROP_RWLOCK_RDLOCK(pd);
>       _PROP_RWLOCK_WRLOCK(pd);
>       _PROP_RWLOCK_UNLOCK(pd);
> 
>       _PROP_RWLOCK_RDLOCK(pa);
>       _PROP_RWLOCK_UNLOCK(pa);
>       _PROP_RWLOCK_WRLOCK(pa);
> 
> The only disadvantage would be that the member containing the lock
> would have to use the same name in "_prop_dictionary" and "_prop_array".
> 
>       Kind regards
> 
> -- 
> Matthias Scheler                                  http://zhadum.org.uk/

i personally prefer the former because it's clearer and
doesn't assume 1:1 mapping between locks and structures.

YAMAMOTO Takashi


Home | Main Index | Thread Index | Old Index