static IConstWorkUnit *getWorkunit(ICodeContext * ctx)
{
    StringAttr wuid;
    wuid.setown(ctx->getWuid());
    // One assumes we have read access to our own wu
    return getWorkunit(ctx, wuid);
}
static IConstWorkUnit * getWorkunit(ICodeContext * ctx)
{
    Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
    StringAttr wuid;
    wuid.setown(ctx->getWuid());
    return factory->openWorkUnit(wuid, false);
}
static IWorkUnit * updateWorkunit(ICodeContext * ctx)
{
    // following bit of a kludge, as 
    // 1) eclagent keeps WU locked, and 
    // 2) rtti not available in generated .so's to convert to IAgentContext
    IAgentContext * actx = dynamic_cast<IAgentContext *>(ctx);
    if (actx == NULL) { // fall back to pure ICodeContext
        // the following works for thor only 
        char * platform = ctx->getPlatform();
        if (strcmp(platform,"thor")==0) {  
            CTXFREE(parentCtx, platform);
            Owned<IWorkUnitFactory> factory = getWorkUnitFactory();
            StringAttr wuid;
            wuid.setown(ctx->getWuid());
            return factory->updateWorkUnit(wuid);
        }
        CTXFREE(parentCtx, platform);
        return NULL;
    }
    return actx->updateWorkUnit();
}
static IConstWorkUnit * getWorkunit(ICodeContext * ctx)
{
    StringAttr wuid;
    wuid.setown(ctx->getWuid());
    return getWorkunit(ctx, wuid);
}