4 ms·
It would have to be very quick as it would need the thread to be started before your object has finished being constructed. So it seems unlikely. What's not cle
by aardvark179 4y ago
It would have to be very quick as it would need the thread to be started before your object has finished being constructed. So it seems unlikely. What's not clear to me from a quick reading of the code is whether the store is actually correct. Although it is only being filled by a single thread that isn't the one that is going to read it on shutdown and I'm not clear on whether there is anything forcing a barrier before the onExit thread has starts reading the hash maps on the nodes.
Actually, is there anything stopping the sampler from taking another sample while onExit is running?
- brewmarche 4y agoWould `volatile` help with the barrier? Re the multi-threading issue, it should be possible to stop the profiler thread in the hook, if we keep a reference to the thread, no?
- aardvark179 4y agoThe fields are final, so they can't be volatile. :-) Using one of the fence methods on VarHandles would ensure the correct ordering. To stop the profiler thread it would be best to provide a controlled method of doing it, there's a lot of way it can be implemented but you probably want to signal it in some way and then do a join() to wait while it shuts down cleanly.
- parttimenerd 4y agoThanks, I implemented it using a boolean flag.