views:

203

answers:

1

Is registering components on castle windsor thread-safe?

I.e., can multiple threads simultaneously register components on the same container instance?

(For the record, yes I am aware that doing so is probably insane.)

+5  A: 

It's quite hard to tell whether a complex piece of software like Windsor is thread-safe or not. Windsor has several subsystems and internal services. And each component registration can do lots of stuff (setting up proxies, different lifestyles, custom dependencies...). AFAIK there are no thread-safety specific tests.

However, assuming you're using the default subsystems and your threads don't add custom contributors, subresolvers, etc (i.e. just plain component registration) it should be thread-safe, since the classes involved in component registration look like they're either stateless or properly locked. The DefaultKernel mostly delegates operations to the various subsystems/internal services, and in particular the DefaultNamingSubSystem (the services maps storage subsystem) is properly locked.

I recommend that you ask on the castle-users or castle-dev google groups, that's where the real Castle gurus are.

Mauricio Scheffer
Thank you for taking the time to look into this, as it seems you actually did research, which I do appreciate. I know it's hard to tell, but I just wanted to know if there was some general knowledge of "Omg don't even think about it" out there. Mucho gracias!
James Thigpen
Castle Windsor is designed to be thread safe and there are no known bugs in multithreaded environment. It _should_ work as expected if your code is well designed.
Krzysztof Koźmic