track CommandCtx
| 195 | |
| 196 | // track CommandCtx |
| 197 | void Globals_TrackCommandCtx |
| 198 | ( |
| 199 | CommandCtx *ctx // CommandCtx to track |
| 200 | ) { |
| 201 | ASSERT(ctx != NULL); |
| 202 | ASSERT(_globals.command_ctxs != NULL); |
| 203 | |
| 204 | int tid = ThreadPools_GetThreadID(); |
| 205 | |
| 206 | // acuire read lock |
| 207 | pthread_rwlock_rdlock(&_globals.lock); |
| 208 | |
| 209 | // expecting slot to be empty |
| 210 | ASSERT(_globals.command_ctxs[tid] == NULL); |
| 211 | |
| 212 | // set ctx at the current thread entry |
| 213 | _globals.command_ctxs[tid] = ctx; |
| 214 | |
| 215 | // release lock |
| 216 | pthread_rwlock_unlock(&_globals.lock); |
| 217 | |
| 218 | // reset thread memory consumption to 0 (no memory consumed) |
| 219 | rm_reset_n_alloced(); |
| 220 | } |
| 221 | |
| 222 | // untrack CommandCtx |
| 223 | void Globals_UntrackCommandCtx |
no test coverage detected