Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #17536

Re: Call Backs

From Willem <willem@toad.stack.nl>
Newsgroups comp.lang.c
Subject Re: Call Backs
Date 2012-02-17 21:58 +0000
Organization Stack Usenet News Service
Message-ID <slrnjjtjcv.129u.willem@toad.stack.nl> (permalink)
References <jhh1aj$43c$1@speranza.aioe.org>

Show all headers | View raw


Edward Rutherford wrote:
) I've read plenty of discussion about callback functions as used in C (ie 
) in qsort).  I'm comfortable with this: really it is a
) function pointer.  What I'm not sure about is how (or if) a
) callback differs to events like GUI's use.  One of the things I
) found about events, at least in a VB6 project I did, is that an event
) can be broadcast to all objects and they can use it if desired (code
) only and GUI objects).  Each object has to have a receive function for
) that event though.
)
) The only way I can see to do event broadcasting with a callback is to
) have a special callback that in turn calls a list of receiver functions
) that would be in each module.

No, the place that handles the events could just have a list of callback
pointers instead of just the one, and call each one in turn.  That's
usually how it's done in other languages too.
 
) For example, a timer that broadcasts a
) time tick every second would call a function (for example)
) Timer_1min(void) that in turn would call functions in all of the modules
) that need to know the time.  I've also thought about a message que, but
) that is begining to sound like too much work.  Is there a better way?

A message queue?  Those are only useful in multithreaded environments, to
send information from one thread to other(s).

What are you actually trying to accomplish?


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Call Backs Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2012-02-15 19:33 +0000
  Re: Call Backs tom st denis <tom@iahu.ca> - 2012-02-15 11:36 -0800
    Re: Call Backs James Kuyper <jameskuyper@verizon.net> - 2012-02-15 15:02 -0500
    Re: Call Backs Devil with the China Blue Dress <chine.bleu@yahoo.com> - 2012-02-15 12:27 -0800
    Re: Call Backs Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-02-16 02:56 -0800
  Re: Call Backs Lew Pitcher <lpitcher@teksavvy.com> - 2012-02-15 15:20 -0500
  Re: Call Backs Devil with the China Blue Dress <chine.bleu@yahoo.com> - 2012-02-15 12:24 -0800
  Re: Call Backs Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-02-15 16:02 -0800
  Re: Call Backs Shao Miller <sha0.miller@gmail.com> - 2012-02-16 01:21 -0500
    Re: Call Backs Shao Miller <sha0.miller@gmail.com> - 2012-02-16 01:25 -0500
  Re: Call Backs Willem <willem@toad.stack.nl> - 2012-02-17 21:58 +0000

csiph-web