Sunday, March 11, 2007

I Promised Myself I'd Never Stoop This Low...

If I've looked depressed recently, this is probably why:


// Let the hacks begin! We really need a compiler...
#define ENTER_RPC_METHOD { \
pthread_mutex_lock(&fblockGlobalMTX); \
rpcMethodStacks[pthread_self()] = \
rpcMethodStacks[pthread_self()] + 1; \
pthread_mutex_unlock(&fblockGlobalMTX); \
}
#define RPC_RETURN { \
int stack = 0;
pthread_mutex_lock(&fblockGlobalMTX); \
stack = --(rpcMethodStacks[pthread_self()]) \
pthread_mutex_unlock(&fblockGlobalMTX); \
if( stack == 0) { \
send(); \
pthread_cond_lock(rpcMutex); \
pthread_cond_wait(rpcConVar); \
pthread_cond_unlock(rpcMutex); \
} \
} return


I don't like programing multi-threaded applications, but I really don't want to do so in C++ with PThreads using Macro support. Deadlines loom...

Update

Okay, I at least realized I could put most of this code into methods, so it's not quite as U-G-L-Y any more.

No comments:

Post a Comment