Skip to content

Conversation

@bodhi
Copy link

@bodhi bodhi commented Apr 17, 2013

Worker threads would previously block waiting for content to be pushed
onto the shared queue. So even though the thread that calls #finish marks the
shared @running variable as false, the worker threads will never wake up to
notice that they should quit, thus causing a deadlock when the calling thread
#joins the worker threads.

Avoid this situation by pushing the process control in-band with the queued
content, to signal to the worker threads that they should wake up and stop
processing.


This is a minimal change to allow #finish to work as expected. What would probably be better is creating the threads on demand as the events are pushed into the API. This would eliminate the need for the queue and process control, at the expense of creating 1 thread per event. I haven't measured the impact of this style on GC or performance (eg. thread startup cost), but I suspect it would be negligible in the operation of a larger project.

… worker threads

Worker threads would previously block waiting for content to be pushed
onto the shared queue. So even though the thread that calls #finish marks the
shared @running variable as false, the worker threads will never wake up to
notice that they should quit.

Avoid this situation by pushing the process control in-band with the queued
content, to signal to the worker threads that they should wake up *and* stop
processing.
@jjb
Copy link

jjb commented Feb 6, 2014

@bodhi what's the scenario where this happens?

@jjb
Copy link

jjb commented Feb 6, 2014

(your description makes is sound like it always happens)

@bodhi
Copy link
Author

bodhi commented Feb 7, 2014

Honestly, I can't remember. We stopped using StatHat a while ago on our project for a couple of reasons, so I haven't looked at it basically since I submitted the pull request.

@jjb
Copy link

jjb commented Mar 3, 2018

I think I've now solved this in a better way here #10

in this commit: b47dd80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants