user/lib/libc/src/threads/thread_info.c
/**
 * Allocates a new thread info block for the given thread. The only information that's filled in
 * is the handle.
 *
 * The returned object will have one reference to it.
 */
Allocates a new thread info block for the given thread. The only information that's filled in
is the handle.

The returned object will have one reference to it.
Allocates a new thread info block for the given thread . The only information that ' s filled in is the handle . The returned object will have one reference to it .
uthread_t *CreateThreadInfoBlock(const uintptr_t handle) {
    int err;
    uthread_t thread;
    memset(&thread, 0, sizeof(thread));
    thread.handle = handle;
    thread.refCount = 1;
    err = mtx_lock(&gState.blocksLock);
    if(err != thrd_success) return NULL;
    void *ret = hashmap_set(gState.blocks, &thread);
    assert(ret || (!ret && !hashmap_oom(gState.blocks)));
    mtx_unlock(&gState.blocksLock);
    return GetThreadInfoBlock(handle);
}
uthread_t * CreateThreadInfoBlock ( const uintptr_t handle ) { int err ; uthread_t thread ; memset ( & thread , 0 , sizeof ( thread ) ) ; thread . handle = handle ; thread . refCount = 1 ; err = mtx_lock ( & gState . blocksLock ) ; if ( err != thrd_success ) return NULL ; void * ret = hashmap_set ( gState . blocks , & thread ) ; assert ( ret || ( ! ret && ! hashmap_oom ( gState . blocks ) ) ) ; mtx_unlock ( & gState . blocksLock ) ; return GetThreadInfoBlock ( handle ) ; }
Allocates a new thread info block for the given thread.
Allocates a new thread info block for the given thread .
// then return the freshly inserted object