retrieve or instantiate new QueryCtx
| 19 | |
| 20 | // retrieve or instantiate new QueryCtx |
| 21 | static inline QueryCtx *_QueryCtx_GetCreateCtx(void) { |
| 22 | QueryCtx *ctx = pthread_getspecific(_tlsQueryCtxKey); |
| 23 | |
| 24 | if(ctx == NULL) { |
| 25 | // set a new thread-local QueryCtx if one has not been created |
| 26 | ctx = rm_calloc(1, sizeof(QueryCtx)); |
| 27 | |
| 28 | // created lazily only when needed |
| 29 | ctx->undo_log = NULL; |
| 30 | ctx->effects_buffer = NULL; |
| 31 | ctx->stage = QueryStage_WAITING; // initial query stage |
| 32 | |
| 33 | pthread_setspecific(_tlsQueryCtxKey, ctx); |
| 34 | } |
| 35 | |
| 36 | return ctx; |
| 37 | } |
| 38 | |
| 39 | // retrieve QueryCtx, return NULL if one does not exist |
| 40 | static inline QueryCtx *_QueryCtx_GetCtx(void) { |
no test coverage detected