Home

June 8th, 2007

02:10 am
I LOVE CODING!

So, it's amazing what reading two 600 page books can do. So in the two days of coding (from scratch)...

The server will sit and listen for connections. (two objects, (A) one thread to listen for incoming requests and when it gets one it takes the connection and puts it in a pool for (B) the request processor. The request processor will be made of 25 threads to process incoming requests, so they'll all be watching the pool, waiting.

The (A)Thread will then say "Yoh you have work" (updateAll()). Like swarms, the first to get to the request freezes the pool (synchronize(pool)) and handles the connection by popping it out of the pool so no one else can get to it. It then let's go of the pool.

Since the request processor threads (B) are all going to need to talk to the database (I already have it connecting to the DB and getting a record), and since I want to save resources they are all going to share one database connection. Since that B-Thread that just got to the request is going to be using the database connection, they'll all have to wait (synchronize(dbConn)) if there's work to be done requiring the db.

The console knows about the AlertObject, and it prefilled it with the question "Hey you got any alerts for me?". Since the b-thread knows the what "common object" (alert object) looks like. It will read the information coming from the console straight into its version of the AlertObject. Now the (B)Thread has its own copy, it'll tell the AlertObject what the "shared" database connection is, and tell the AlertObject "find out for yourself".

The alertobject is going to fill itself up (with alerts) by contacting the database and return to the (B)thread that called it. The (B)Thread is going to go, OK, you don't need the dbconnection so let me allow the other 24 (B)threads to use the database connection.

Since the (B)Thread knows that the console knows what the AlertObject looks like - the console just sent him an empty one - it's going to stream the alertobject back to the console... who, by the way, is still waiting for a response.

That thread is then going to go back to the pool to check for more connections that the A-Thread may have dropped off.... but alas, some other B-thread got there first, so he'll just have to wait.

Phew... I LOVE CODING!

01:33 pm
My Thermos, oh, my Thermos

So, if anyone has known me in the last couple of years (Since 2002) they should know that I always carry a thermos with me. If not visible it's probably in my backpack. Sometime in the end of April, I lost my Thermos. Yes, horror of horrors! I thought I knew where it was, but after two weeks I gave up hope.

I went to Joe's to see if he had Thermoses. NOPE. I mean he did, but they were only 1Qt. UGH. They recommended Fante's, a kitchen/restaurant wares store in the Italian Market. NOPE, they had the same ones Joe's had. I went to Kmart to see if they had them there... afterall that's where I got my first one. NOPE. I went to the "Stanley THERMOS" site... and they didn't quite have my old one, but they had a comparable one for $40. So I went to Amazon, and ordered it... NOPE... Estimated Ship date... ONE MONTH FROM NOW. I cancelled my order and decided to look around some more...

Target had a 1QT, and 2L thermos, but ... it wasn't THERMOS. It was some other brand... NOPE. Today, I had had enough... Screw it. I am going to get the one off of the Stanley site. So I type in www.thermos.com (because I can't remember the Stanley site name).

BOOM!!! RIGHT THERE! My beautiful good old thermos! http://thermos.smartermall.com/product.asp?sku=2349024 AND it was $30. :) In four days, I should have my precious clone back again, to fulfill my libatious pleasure!

So now I just have to order 2Kilos of Yerba Mate because I am down to my last airtight container.