Tuesday, October 21, 2014

Changes 10/21/14

Life Achievements:

  • I managed to shut down Aki's computer using only my face.  I pressed the power button with my finger to open the shutdown menu, but he grabbed my hands.  I used my nose to push the down arrow twice and then the enter key, which selects the standby option.

Java:

Ruby:

  • Removed the condition variable wait from threading_queue_pooled.rb
  • The condition variable allows the programmer to sleep a thread while waiting on a resource from another thread.  Once the resource is available, the #signal method is called, which releases the lock on one of the threads waiting on the variable. 
  • However, I realized that I actually don't want this in my case, because Queue#pop already sleeps the thread when empty, making the condition variable redundant.  Additionally, the ConditionVariable#signal method doesn't do anything if the condition variable isn't currently causing the thread to wait, so if it is called when the thread is parsing stuff it is completely ignored.  Therefore, the threads always ended up waiting forever, because each element pushed to the queue would only be signaled once, and if that signal happened to be ignored, the condition variable would continue to pause the thread, even though there were more tasks in the queue.

2 comments:

  1. I guess I forgot to push the change to the git repo, I'll do that at some point.

    ReplyDelete
  2. Nice work with the code source! Since this.size is an instance variable in Java, your function here is O(1). It had to be set when the String was being created. I don't know enough about how Java implements Strings, but I'm thinking it was an O(n) operation at that point.

    ReplyDelete