[haiku-3rdparty-dev] Thread Control

  • From: David Rawson Couzelis <drcouzelis@xxxxxxxxx>
  • To: Haiku 3rd Party Development Mailing List <haiku-3rdparty-dev@xxxxxxxxxxxxx>
  • Date: Mon, 25 Jun 2012 22:37:03 -0400

This is a follow-up to this thread:

//www.freelists.org/post/haiku-development/Creating-a-new-thread

I'm making an RSS feed reader. I want the application to automatically
check for updates every hour. I'm confused about the best way to
implement this.

I wrote a function that has an infinite loop. It will connect to each
RSS feed and check for updates, then "snooze" for 1 hour:

  int32 update_thread_function(void* data)
  {
    while (true) {

      // Update each RSS feed
      // right HERE!

      // Wait for one hour
      snooze(ONE_HOUR, B_NORMAL_PRIORITY);
    }
  }

I call the function using "spawn_thread" and "resume_thread" when the
application starts.

Is this a good way to do it? Do I need to stop the thread myself when
the application quits? What would be the best way to stop the thread? I
don't want memory leaks or data corruption.

Please let me know if I didn't explain my situation very well. :P

Thank you.

Other related posts: