Thread: I need some help about delaying a method from returning the answer, Asynchronous..

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    1

    I need some help about delaying a method from returning the answer, Asynchronous..

    Hi
    Thank you for reading my post.
    I have an interface which has two method with several parameters and I should implement this method to complete a task, eg: calculating a series.

    The tester program will load my "dynamic shared library" and call initialize method for calibration. then It create several threads to call the worker method named calcSeries(......) . each thread may call the method several times.

    for example following 4 calls need to be issued by one of the above threads.

    1-calcSeries(1,5,7,2)
    2-calcSeries(3,9,2,1)
    3-calcSeries(3,7,9,2)
    4-calcSeries(5,4,8,6)

    Is it possible to return the result asynchronously ?
    for example I get all calls and then return the result when I complete them?
    Maybe 4th call complete before other ones.


    Thanks.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    A normal function has to return a result synchronously. If you want asynchronous results, you have to look into alternatives to normal return values, such as futures. Google them.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    It's possible. Why do you want an asynchronous API? Why not just make calcSeries() a synchronous call then the caller can put the call in a separate thread if they want.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  3. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 03:25 PM
  4. code help :)
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 02-28-2002, 01:12 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM