Re: threads without threads

From: Thomas Matthews (Thomas_MatthewsSpitsOnSpamBots_at_sbcglobal.net)
Date: 08/27/04


Date: Fri, 27 Aug 2004 20:47:51 GMT

sindica@gmail.com wrote:
> Hello,
>
> I have a counter loop which actually executes in a different thread.
> The thread is there to check for a connection time out. However due to
> some limitations, I cannot use pthreads or any OS dependant components
> (my code should run on both windows and linux). I have to relegiously
> stick on to ANSIC standard. Does ANSI C provide any inherent function
> which could accomplish what I intend to do. Or putting it otherway,
> how can I just deviate from my direct execution path and just return
> to it after a stipulated time has elapsed.
>
> ~saraca

As far as sleeping goes, there is no support for task suspension
in the ANSI C language.

However, you _could_ write a wrapper function for your platform
specific code. Just supply different implementations based upon
the platform. This is what many cross platform project do.

-- 
Thomas Matthews
C++ newsgroup welcome message:
          http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq:   http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
          http://www.comeaucomputing.com/learn/faq/
Other sites:
     http://www.josuttis.com  -- C++ STL Library book


Relevant Pages

  • Re: Where is the FAQ?
    ... Many thanks to Greg! ... >the final URL for the FAQ will change. ... but without it becoming platform specific. ... >put up some web pages with common platform related problems (getting ...
    (alt.comp.lang.learn.c-cpp)
  • Log File Program: problems btw compilers
    ... I compiled it with g++ 3.3.1 and it executes with no errors. ... inline void Log_File::resume ... C++ Faq: http://www.parashift.com/c++-faq-lite ... http://www.josuttis.com -- C++ STL Library book ...
    (comp.lang.cpp)
  • Re: exe to C++ source code
    ... Many compilers, which compile to different ... platform specific instructions. ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (comp.lang.cpp)
  • Re: Getting selected text from last active program
    ... The output facilities ... Anything else depends on the platform. ... Some platforms provide "clipboards" for passing data between ... C++ Faq: http://www.parashift.com/c++-faq-lite ...
    (comp.programming)
  • Re: ostream::write() error result
    ... > badbit (critical error in stream buffer) ... > but I would like to know if there was not enough free disk space to perform ... then use some platform specific functions for determining ... Read the FAQ and Welcome.txt links below. ...
    (comp.lang.cpp)