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

This is a discussion on I need some help about delaying a method from returning the answer, Asynchronous.. within the C++ Programming forums, part of the General Programming Boards category; Hi Thank you for reading my post. I have an interface which has two method with several parameters and I ...

  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,893
    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,701
    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, 10:42 AM
  2. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 10:50 PM
  3. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 04: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21