bolshakov / stoplight

:traffic_light: Traffic control for code.
http://bolshakov.github.io/stoplight/
MIT License
384 stars 40 forks source link

Thread Safety #87

Closed AndreasWurm closed 8 years ago

AndreasWurm commented 8 years ago

Hey,

Stoplight with MemoryStore is not threadsafe. It would be awsome if stoplight would be usable in threaded ruby code. The only shared state between Stoplights seems to be the class variables in Stoplight::Light and the DataStore.

tfausak commented 8 years ago

I would like Stoplight to be thread safe, but I don't have a lot of experience with thread safety in Ruby. If I understand you correctly, we would have to do at least two things to make Stoplight thread safe:

Is that correct?

AndreasWurm commented 8 years ago

First off, a bit of clarification why we should care about threadsafety. Its not only about writing concurrent code ourselfs but another important usecase is using threaded libraries or frameworks for example just using Rails in a threaded server, like Puma or Phusion Passenger with PassengerConcurrencyModel thread.

I'll give it a shot during the next week and come back to you with a suggested implementation.

tfausak commented 8 years ago

Ok great! I will be happy to review a pull request. Let me know if I can help.

tfausak commented 8 years ago

Any movement on this?

AndreasWurm commented 8 years ago

sorry mate havnt found the time yet, this weekend is also pretty stuffed, give me till next friday

tfausak commented 8 years ago

No rush.

tfausak commented 8 years ago

Did #92 close this, or is there more to do?

AndreasWurm commented 8 years ago

think its fine :thumbsup:

tfausak commented 8 years ago

Great, thanks!