Open astro opened 9 years ago
@jakemack thanks, your contribution is greatly appreciated!
I wonder what was specific reason to prefer thread_variable_get
/thread_variable_set
over plain []
/[]=
? IMO all those class variables making more sense in fiber-local context than in "shared-between-all-fibers-thread-local-context".
That's a good point, I believe you are right.
@musybite Is this a change you'd want me to make and submit or is it quick and easy enough for you to implement?
Actually there is a use case for thread local variables: Celluloid runs actors in separate threads, but different calls to actors are run in different Fibers. Testcase shows that fibers are different and variables are lost:
I, [2015-12-08T10:34:21.428386 #19221] INFO -- : : thread = '#<Celluloid::Thread:0x007f827b1b8500>' 'second', fiber = '#<Fiber:0x007f8279a3d9e8>' ''
I, [2015-12-08T10:34:21.428514 #19221] INFO -- : : thread = '#<Celluloid::Thread:0x007f8279a26180>' 'first', fiber = '#<Fiber:0x007f8279a3d1f0>' ''
I, [2015-12-08T10:34:21.429111 #19221] INFO -- : : thread = '#<Celluloid::Thread:0x007f827b1b8500>' 'second', fiber = '#<Fiber:0x007f827b863b20>' ''
I, [2015-12-08T10:34:21.429280 #19221] INFO -- : : thread = '#<Celluloid::Thread:0x007f8279a26180>' 'first', fiber = '#<Fiber:0x007f827b8631e8>' ''
So at least for this/my usecase fiber-local variables are no-go.
Sorry for long response time :) So, we have at least couple of valid use-cases for thread-local variables and i see no real reason for fiber-local variables. I guess i'll adapt @jakemack's MR.
I'm curious if this will ever be merged? @musybite are you still actively maintaining this gem?
Got this by mail, leaving it here for the new maintainer, @musybite