LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2008, 06:25 PM   #16
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled

ntubski is right.

The "ideal" solution will vary, but the basic idea is correct:

1. Polling is bad

2. You should always avoid polling by blocking.
Here, that means blocking on XNextEvent ()

3. If you want to do something periodically, you should set up some kind of "event" that will "signal" you at the right time.

Ntubski's suggestion about setting up an OS-level timer is a good idea.

If you're using Xt, Qt or GTK, you could use one of their timers. If you felt like spawning a thread, you could could put your "sleep()" there. There are *lots* of alternatives.

'Hope that helps .. PSM

PS:
Did I mention "Polling is Bad"? It *is* bad. "Evil", in fact. Honest!
 
Old 04-20-2008, 07:52 PM   #17
thedevilsjester
Member
 
Registered: Apr 2005
Posts: 39

Original Poster
Rep: Reputation: 16
@ntubski Yeah that looks like the only real solution, Ive done that before back in my Windows years, but didnt want to write all that code for a blinking cursor.

@paulsm4
The main selling point of my app is that it doesnt use any of these toolkits so that its extremely light weight.

I know polling for messages is bad, which is why I block in every area except this. Its such a simple thing I didnt want to have to complicate it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
does killing child processesreduce CPU load average?? expeliarmus Linux - Newbie 1 08-02-2007 12:52 AM
does killing child processes reduce CPU load average?? expeliarmus Linux - General 2 08-02-2007 12:43 AM
does killing child processes reduce CPU load average?? expeliarmus Programming 1 08-02-2007 12:19 AM
My browser, all day today: 'waiting for linuxquestions.org...' ..waiting.. waiting .. GrapefruiTgirl LQ Suggestions & Feedback 18 05-25-2007 05:35 AM
smbfs killing my CPU badMoJo Slackware 0 02-02-2003 04:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration