I have a custome method that adds text to a log file, the text is PRINTed in sections, and there's two threads that are using the method. What would be a good way to queue up each addLog() so that only one is ever handled at a time, thus guaranteeing newlines and keeping the log from becoming a jumbled, unreadable mess.
I've been thinking of Queue, but the only examples I see are used to pop information between threads... I just want to do them one at a time to prevent issues.
so you can see where you would want it to output Stuff1Thing1\nStuff2Thing2\n infinitely, but instead it gets jumbled because both threads are writing simultaneously and this causes one to happen in the middle of another before the newline
Nevermind, figured it out. I setup a thread to pop the queue constantly and redirected the log calls to add the value to the queue.
because it's a server, hosting multiple different services that I want running in sync, and they all print to the same console
ljarvis, I'm pretty stuck on using tabs, sorry, it's engrained in my mind... believe it or not however, 90% of my code in snake_case, that method was one that got away from a late night of coding
yup I just compared it against the stdlib/securerandom copy included in my current version of ruby and I see exactly what is missing. I'll fork it, fix it, and submit a pull request