// Listing 1 // Listing 2 code/ch15 int ACE_TMAIN (int, ACE_TCHAR *[]) { HA_ControllerAgentProxy controller; ACE_Future<int> results[10]; CompletionCallBack cb (controller); for (int i = 0 ; i < 10; i++) { results[i] = controller.status_update (); results[i].attach (&cb); } ACE_Thread_Manager::instance ()->wait (); return 0; }
// Listing 5 // Listing 6 code/ch15 int ACE_TMAIN (int, ACE_TCHAR *[]) { HA_ControllerAgentProxy controller; ACE_Future<int> results[10]; for (int i = 0 ; i < 10; i++) results[i] = controller.status_update (); ACE_OS::sleep (5); // Do other work. // Get results... for (int j = 0; j < 10; j++) { int result = 0; results[j].get (result); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("New status_update %d\n"), result)); } // Cause the status_updater threads to exit. controller.exit (); ACE_Thread_Manager::instance ()->wait (); return 0; }