Thread: async programming question

  1. #1
    Registered User
    Join Date
    Jul 2017
    Posts
    13

    async programming question

    I have two queues and two functions.

    Code:
    Queue send_q, recv_q;
    
       Function_a_client_request_handling( request, Response){
      
         //Processed data send over send_q;
    
         // waiting for some data from Recv_on_recv_q().
       }
    
       Recv_on_recv_q(){
            //it will check on recv_q on all times.
              If it recev any data, check which Function_a_client_request_handling the    data   should be forwarded. 
    }

    My question is that how to do this logic in C?

    Main question how to forward the data from Recv_on_recv_q() function to Function_a_client_request_handling asynchronously?

    Thanks
    Sothy

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,728
    Take a look at this website page, it talks about ways to signal events between threads.
    C++11 Multithreading – Part 6: Need of Event Handling – thisPointer.com
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Jul 2017
    Posts
    13
    It is in C++. MY program is in C. can I link C++ with my C program?

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,728
    Yes you can. I posted it without thinking though, mostly because it's standard C++ and not some 3rd party library. If you want to use C exclusively, you can take a look at pthreads.
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Jul 2017
    Posts
    13
    It means you want to make two functions (Function_a_client_request_handling( request, Response) and Recv_on_recv_q ) in two threads and run. am I right?
    Main issue is that there are many threads for Function_a_client_request_handling( request, Response) for each request and one thread for Recv_on_recv_q. how to do?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Understanding Async Code
    By EverydayDiesel in forum C++ Programming
    Replies: 9
    Last Post: 04-01-2016, 08:19 AM
  2. Threads vs async events
    By zacs7 in forum Tech Board
    Replies: 4
    Last Post: 02-10-2010, 10:29 PM
  3. async socket issues
    By ZerOrDie in forum Windows Programming
    Replies: 2
    Last Post: 03-16-2003, 06:10 PM
  4. Error on Async socket startup!
    By SyntaxBubble in forum Windows Programming
    Replies: 4
    Last Post: 03-16-2002, 07:36 PM
  5. Async Socket Examples?
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2002, 06:08 PM

Tags for this Thread