Re: [Banshee-devel-list] Re-entrant locks in ServiceManager



On Sat, 2008-01-26 at 16:43 +0100, Ruben Vermeersch wrote:
   
> Is there any specific reason to have two copies of this method? The lock
> statement in C# is re-entrant, as such, I would like to proposed
> attached patch, which gives no noticeable difference in starting up.

Absolutely not. I'm not sure what I was thinking!

> However, as I'm not sure why you wrote it like this, I wanted to check
> up with you first. Is there any reason for the two methods
> (performance?)? If so, do enlighten me, I'm here to learn.

No reason - in fact, calling a method probably takes a lot longer than
acquiring a lock, so it's possibly a performance hit. Who knows. I think
I was coming off a lot of C work when I started writing this class, so I
probably wasn't in a solid C# mindset. 

> Otherwise, do you have any objections against me committing this? Less
> code always makes me feel better.

Please, commit away.

> On a side note:  // TODO: Add something like
> ServiceManager.NotifyStartup ("InterfaceActionService", Initialize);
> 
> Is this because you can't (at least not that I know of) have
> parametrised/generic events? Basically a workaround for the lack of:

No, this has to do with wanting to ensure a service is started before
you allow an operation to continue.

For instance, if the code in Initialize depends on
InterfaceActionService, then Initialize should not run until that
service has loaded. What I meant was that I wanted a method that makes
this easier, since it will be quite common to do:

if "service" is not loaded:
  notify_when_started ("service", method_to_run)
else:
  method_to_run

So it'd just be nicer to have

ServiceManager.NotifyStartup<InterfaceActionService> (Initialize)

or something. Nothing stops the implementation from using generics.

Best,
Aaron

> ServiceManager.ServiceStarted<InterfaceActionService> += delegate
> Initialize;
> 
> 
> Cheerios!
>    Ruben
> 
> 
> PS: Yes, I should've been studying...
> PS2: Putting -devel on CC, in case anyone happens to know about some
> smart trick with events.
> 
> 
> --
> Ruben Vermeersch (rubenv)
> http://www.savanne.be



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