MCPcopy Create free account
hub / github.com/acl-dev/acl / thread_init

Function thread_init

lib_fiber/c/src/fiber.c:159–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159static void thread_init(void)
160{
161 THREAD *local;
162
163 local = (THREAD *) mem_calloc(1, sizeof(THREAD));
164
165 local->original = fiber_real_origin();
166 local->running = NULL;
167 local->fibers = NULL;
168 local->size = 0;
169 local->slot = 0;
170 local->nlocal = 0;
171
172#ifdef SHARE_STACK
173 local->stack_size = __shared_stack_size;
174 local->stack_buff = mem_malloc(local->stack_size);
175# ifdef USE_VALGRIND
176 local->vid = VALGRIND_STACK_REGISTER(local->stack_buff,
177 local->stack_buff + __shared_stack_size);
178# endif
179 local->stack_dlen = 0;
180#endif
181
182 ring_init(&local->ready);
183 ring_init(&local->dead);
184
185#ifdef THREAD_LOCAL_DYNAMIC
186# if defined(_WIN32) || defined(_WIN64)
187 pthread_fkey_create();
188# endif
189
190 if (pthread_setspecific(__fiber_key, local) != 0) {
191 printf("pthread_setspecific error!\r\n");
192 abort();
193 }
194#else
195 __thread_local = local;
196#endif
197}
198
199static pthread_once_t __once_control = PTHREAD_ONCE_INIT;
200

Callers 1

fiber_checkFunction · 0.70

Calls 6

mem_callocFunction · 0.85
mem_mallocFunction · 0.85
ring_initFunction · 0.85
pthread_fkey_createFunction · 0.85
pthread_setspecificFunction · 0.85
fiber_real_originFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…