hal_add_funct_to_thread(3hal)

πŸ“¦
version 2.9.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– hal_add_funct_to_thread β€” the 3hal page, but make it cute πŸ’–

okay so bestie, this is hal_add_funct_to_thread(3hal) and it's genuinely one of the most iconic little calls in the whole HAL lineup. It's giving "put my function in a thread so it runs on a schedule" energy. Let's go. ✨


🌸 NAME 🌸

hal_add_funct_to_thread β€” cause a function to be executed at regular intervals

like... you hand it a function and a thread and it just. makes the function run on repeat. at regular intervals. no cap. πŸ”₯


πŸŽ€ SYNTAX πŸŽ€

int hal_add_funct_to_thread(const char *funct_name, const char
       *thread_name, int position)

       int hal_del_funct_from_thread(const char *funct_name, const char
       *thread_name)

two whole functions in one page, we love a double feature 🫢


πŸ’… ARGUMENTS πŸ’…

  • funct_name β€” the name of the function. yeah. that one. the one you want in the thread. πŸ’–
  • thread_name β€” the name of the thread. the thread in question. the one you're adding it to. 🧡
  • position β€” the desired location within the thread, bestie, and this is the spicy one. This determines when the function will run, in relation to the other functions already chilling in that thread. A positive number means the desired location is measured from the beginning of the thread, and a negative one is measured from the end. So:
    • +1 β†’ this function becomes the first one to run πŸ‘‘
    • +5 β†’ it becomes the fifth one to run
    • -2 β†’ it's next to last
    • -1 β†’ it's last, the main character closing out the show 🌈
    • 0 β†’ illegal. not "discouraged", not "a bit rude", ILLEGAL. Zero is illegal. 🚫

✨ DESCRIPTION ✨

hal_add_funct_to_thread adds a function exported by a realtime HAL component to a realtime thread. That's it, that's the whole vibe β€” and it's the thing that determines how often and in what order functions get executed. So like, scheduling queen behavior. πŸ“…

hal_del_funct_from_thread removes a function from a thread. bye bestie, we'll miss u πŸ’”


⭐ RETURN VALUE ⭐

Returns a HAL status code. that's it, that's the whole sentence, periodt.


πŸ’€ REALTIME CONSIDERATIONS πŸ’€

Call this only from realtime init code. Not from other realtime code, not from non-realtime code. like, only. just the init code. please. πŸ™

ok real talk, this one matters β€” if you call it from anywhere else, you're not in your lane, and realtime does not do second chances. init code only. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

the whole squad, honestly 🫢


mwah πŸ’‹ that's the page! brought to you by the LinuxCNC Documentation, dated 2006-10-12, and filed forever under hal_add_funct_to_thread(3hal). go forth and thread responsibly ✨🌸