iv_thread(3)

πŸ’– iv_thread β€” ivykis thread convenience functions πŸ’–

okay so bestie, this is iv_thread(3), from the ivykis programmer's manual, and it's literally the ✨threading helper✨ page. two little functions that make threads and ivykis play nice together. no cap, it's short but it's important.


✨ NAME ✨

iv_thread_create, iv_thread_set_debug_state β€” ivykis thread convenience functions πŸ§΅πŸ’…


🌸 SYNOPSIS 🌸

#include <iv_thread.h>

int iv_thread_create(const char *name, void (*start_routine)(void *),
void *arg);
void iv_thread_set_debug_state(int state);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, iv_thread_create is basically a glow-up wrapper around pthread_create(3) πŸ‘‘. it does the normal thread-making thing, BUT it also keeps an ivykis main loop reference alive in the calling thread for as long as the created thread is alive. and heads up: the calling thread must be an ivykis(3) thread, i.e. it has to have had iv_init(3) called in it. that's the vibe check, no exceptions πŸ™ˆ.

and why does it hold that reference, you ask? because holding a reference on the calling thread's ivykis event loop means the calling thread will not return from its ivykis main loop before the created thread exits 🌈. and that matters so much, because if it did, cleanup that's still happening over in the created thread could get interrupted when the calling thread then goes and calls exit(3) πŸ’€. so yeah, the reference is the whole point. it's giving protective bestie energy fr fr.

the tea on the new thread though: the created thread does not need to be an ivykis thread ✨. it can just be a regular thread doing regular thread things. iconic.

now, the debug mode πŸŽ€. if you call iv_thread_set_debug with a nonzero argument, it turns debugging ON, and then it prints a debug message to standard error every time:

  • a thread gets created via iv_thread_create 🐣
  • a thread that was created that way terminates πŸͺ¦
  • destruction of such a thread gets signaled back to the calling thread πŸ“¬

so like, three whole moments. very thorough of it tbh.

one more thing, for the inter-thread signaling? iv_thread uses iv_event(3) 🫢. that's just how it do.


πŸ‘€ SEE ALSO πŸ‘€


and that's the whole page, bestie, you ate it πŸ’–βœ¨ this beauty is from ivykis, dated 2010-09-13, and it's page iv_thread(3) πŸŽ€ go forth and thread responsibly, mwah πŸ’…πŸ¦‹πŸŒΈ