qt_begin_blocking_action(3)

πŸ“¦ version 1.22^20251007gitcedb1fc, in fedora 43, fedora 44

πŸ’– qt_begin_blocking_action(3) πŸ’–

okay bestie, welcome to the libqthread manual, page three of qt_begin_blocking_action β€” yes the whole thing, both functions, we're doing this together 🫢


✨ NAME ✨

qt_begin_blocking_action, qt_end_blocking_action β€” the little duo that tells the runtime "hey, this part is gonna block" πŸ’…


✨ SYNOPSIS ✨

#include <qthread/io.h>

void
qt_begin_blocking_action(void);

void
qt_end_blocking_action(void);

literally that's it, two void functions, no arguments, no return values, no drama 🌸


✨ DESCRIPTION ✨

so here's the tea β˜• β€” these two functions exist to isolate sections of code that may block and that aren't intercepted in some other way. super handy when you're trying to inter-operate with third-party libraries, because those libraries did NOT get the memo about your fancy runtime and they will absolutely just sit there and block. no cap.

here's what actually goes down when you call qt_begin_blocking_action():

  • the task that calls it gets descheduled and enqueued in the system call queue πŸ“₯
  • once it's in there, it gets treated exactly the same as anything else in that queue β€” same rules about the number of concurrent operations permitted, same relationship to the servicing threads. no special treatment, no main character energy here, it just queues up like everybody else πŸ’€
  • after calling qt_begin_blocking_action(), the task wakes up in an external, dedicated thread 🧚 and that's where it can do the blocking operation β€” without any fear that doing so would hijack the original worker thread. iconic. that's the whole point. the worker thread stays safe and un-hijacked, periodt πŸ‘‘
and once the blocking operation is done? you must call qt_end_blocking_action(). not "should", not "maybe later" β€” must. πŸ™ˆ that call is what reschedules the task in the standard scheduling queues, aka it puts your task back where it belongs. forget it and your task is just... out there. in the void. bestie please don't do that 😭

✨ SEE ALSO ✨

if you liked this page you're gonna be obsessed with these πŸ’–


and that's the whole page babes πŸŽ€ this one's from libqthread, dated AUGUST 2012, and it's filed under qt_begin_blocking_action(3). go forth and block responsibly πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from