Sunday, March 28, 2010

18 Till I Die

The last couple of weekends have been happening in terms of socio-cultural interactions and chores to take care of. It all started with the Shreya Ghoshal concert on Friday the 19th. It was an evening concert at 7 pm and after a first hour or so of sidey dancers and the "band" introductions, Shreya was singing some of her famous numbers alongside the SaReGaMa fame Shivprasad. The acoustics in the Dorton arena left much to desire, but once we moved down from our seats closer to the stage, it wasn't bad at all. We could see her sing and dance and hear her hit difficult notes almost at will. A few close friends and I had a good shake-a-leg to some hit numbers like Zoobi Doobi and Dola Re...After the break, she sang some regional songs on public demand including a famous Marathi lavani "Reshamaachya reghaani". All in all while Shreya continued to dazzle, IMHO the performance was strictly alright owing to the sorry acoustics and sad dancers. Not to mention the urdu-esque wannabe shayarana compere Niharika.

Following two days were spent amid loud music and repetitive dance performances at the India Fest. The only highlight for us were a bunch of close friends singing and dancing on stage. While HK sang the Jaane Kya Chahe Mann from Pyaar Ke Side Effects, HR stuck to the more safer Mitwa from Lagaan. "Useless" also was part of a dance number called India Kaleidoscope which included a montage of dances from hit movie songs like Prem Ki Nayya and Aahun Aahun. Apart from the dance and singing performances of these dear ones, the iFest was a loud melee for the most part. I was left with a big headache at the end of those two weekend days.

Sunday was spent at the R's place playing "lagori" and flying "kite" (just cheel chill just chill) amid nice evening tea and then unwinding playing Mafia and eating a pizza dinner. To top it off, we played Table Tennis at 11.00 pm at night to make it a fun-filled amazing weekend.

During the week I made a generous contribution of a grand to the Honda Motor Corp. trying to do manicure, pedicure and the likes on my sweet sexy coupe. Those guys know how to unstitch the pockets out of your jeans...sigh.

This weekend was Sifar's birthday weekend. The big 3-0. But he's managed to keep himself upbeat like they say 30s is the new 20s or something like that. The b'day started with a customary visit to the temples followed by a buffet lunch with a couple of co-workers at CoolBreeze. My head was clogged in the morning due to some seasonal cold, and I was craving for the spicy hot rassam at the desi place. After a sumptuous lunch, I managed to retire to a nice long afternoon Siesta. Although, I missed a few calls from people wishing me b'day, the afternoon nap was awesomeness throughout. The evening was spent with cake-cutting and a khichadi dinner at AG and HR's place. Thanks guys for making it special.

Thanks also to everyone of you who called remembering my big day and making it special. The social networking boom gives people easy access to each other's birthdays and makes it possible for us to post wishes on our friends'/family's online profiles. Many thanks are therefore due to those who posted on my wall and scrapped in my scrapbook as well. Needless to say you all are the reason I exist, you all are the ones who make this journey worthwhile.

Hoping to put the literal and figurative icing on the cake with a birthday dinner @ The Cheese Cake Factory....the revelry continues....the exuberance of youth (of the past?) beckons...the 30 something mind croons 18 Till I Die...

Cheers,
Sifar.

boost::bind and boost::function awesomeness throughout

On Thursday I was helped by a co-worker to look more closely into boost::bind and boost::function. Its just awesome what you can do with these two together. Say you are writing a library which intends to provide a thread-safe way of accessing a certain structure (ElementType) for the users of your library. In a typical case you would have a container that contains some n objects of ElementType and you want the user to be able to iterate over these. A cool way to do this is to let the user pass a function delegate for your API to call within the thread-safety semantics of your library code. For instance if you had a container ElementContainer every access to which was made thread-safe using an ACE_Guard with a local mutex variable, then you can provide the users of your library an element visitor something to the effect of:

typedef boost::function1 <> ElementVisitor;

and then provide a public API function:

bool VisitElements(const Key& key, const ElementVisitor& visitor);

What the above psuedo-code does is it provides the user a way to iterate thru' the ElementContainer (which contains objects of ElementType) in a thread-safe way that's transparent to the user using a key to find which elements to iterate over. All the user needs to do is instantiate an ElementVisitor delegate which takes the ElementType as a const ref argument and do his mumbo jumbo inside the delegate which would be called inside the context of the library.

But the magic only begins here. boost::bind can be used to tie any random caller function to the ElementVisitor. And club this with boost::ref and boost::cref, you can also have multiple return types in the caller functions. For instance let's say the user of the library has a function as below:

void UsersClass::ElementVisitorFunc(uint32_t arg1, uint32_t arg2, const ElementType& elem);

this can be bound to the ElementVisitor as below:

ElementVisitor del = boost::bind(&UsersClass::ElementVisitorFunc, this, arg1, arg2, _1);

Whats magical about this is although to the caller this is a function call with three arguments, to the library that provides a thread-safe API to visit and access the contained ElementType objects, its a function call with a single argument of type const ElementType&.

Just awesomeness throughout. Thanks DJ and KR for introducing me to this wonderful visitation technique.

Sifar.

Sunday, March 7, 2010

The Bridge Over The Enoxa

These were two prosperous kingdoms on the either side of the mighty Enoxa. The Enoxa would freeze in the cold ghastly winter of the north and that's about the only time people from either kingdoms could visit each other. Enoxa's basin was wide and its current strong to forbid any human movement otherwise. In winter however, it would snow a lot and the entire river would freeze. Paradoxically, the dark harsh winters was a time of merriment for people of the two kingdoms who had kins on either sides. The peoples of the two kingdoms would visit each other share gifts, spend valuable time together before it was time again for the Enoxa to melt away their joys.

Both the kings summoned their generals and commanded them..."Generals, our brethren can't meet their blood relations otherwise but in winter, we need to build a bridge during this approaching winter and make it survive the strong currents of the Enoxa when it melts. Summon the best of our architects/engineers and build a plan to get it done".

And so the two fiercest of generals that the entire north knew took the task (at their respective master's orders) to a war-footing. The generals had only 5 months. The winter had already started to set. The Enoxa was slowly freezing. The black shadow of death was slowly being cast. The generals had to summon their best men, come up with a plan and build the bridge of hope across the Enoxa. So the best architects that both the kingdoms had were sought; they came up with a design and work started after a couple of months over the frozen Enoxa.

The gritty workers from both the kingdoms started to work together, the work of digging huge bores thru' the frozen waters of the Enoxa, laying a deep foundation some 50 feet beyond where the frozen waters met the ground. They toiled day and night, they moved huge stones and constructed columns from either end of the Enoxa's large basin. They built upon the foundation that they had made; created aqueducts for the water to flow thru' so it would stand the test of the Enoxa's currents in summer. Everything looked good and the bridge looked well on the way to completion.

Until one fine new moon night the two supervising generals, over some drunken revelry, had a fight. Each burning in the fury of their egos, withdrew their workers from their side of the bridge and called it quits. The bridge of hope suddenly looked dull and perishing under the moonless night sky. The stars shone brightly, but down below, the bridge was dilapidated. Weeks passed by and the unfinished bridge with its arched stone columns started sagging as the water started to melt. The kings, oblivious to the happenings of the fateful night, were eager to see how their famed generals had done on the so called bridge of hope. The generals hurriedly re-visited the site and were saddened by what they saw. They soon realized that in their brief moment of stupidity they had blew the bridge and it would never get done now. It was too late then...atleast for that winter.

The Enoxa is a symbol of time and bridges are the relationships that we build during our life over time...don't burn them before they are even made.


--Sifar.