MCPcopy Create free account
hub / github.com/boostorg/build / try_wait

Function try_wait

src/engine/execnt.c:794–923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792static int try_wait_helper( twh_params * );
793
794static int try_wait( int const timeoutMillis )
795{
796#define MAX_THREADS MAXJOBS/(MAXIMUM_WAIT_OBJECTS - 1) + 1
797 int i;
798 int num_active;
799 int wait_api_result;
800 HANDLE active_handles[ MAXJOBS + MAX_THREADS ];
801 int active_procs[ MAXJOBS + MAX_THREADS ];
802 unsigned int num_threads;
803 unsigned int num_handles;
804 unsigned int last_chunk_size;
805 unsigned int last_chunk_offset;
806 HANDLE completed_event = INVALID_HANDLE_VALUE;
807 HANDLE thread_handles[MAXIMUM_WAIT_OBJECTS];
808 twh_params thread_params[MAX_THREADS];
809 int result = -1;
810 BOOL success;
811
812 /* Prepare a list of all active processes to wait for. */
813 for ( num_active = 0, i = 0; i < globs.jobs; ++i )
814 if ( cmdtab[ i ].pi.hProcess )
815 {
816 if ( num_active == MAXIMUM_WAIT_OBJECTS )
817 {
818 /*
819 * We surpassed MAXIMUM_WAIT_OBJECTS, so we need to use threads
820 * to wait for this set. Create an event object which will
821 * notify threads to stop waiting. Every handle set chunk should
822 * have this event as its last element.
823 */
824 assert( completed_event == INVALID_HANDLE_VALUE );
825 completed_event = CreateEvent(NULL, FALSE, FALSE, NULL);
826 active_handles[ num_active ] = active_handles[ num_active - 1 ];
827 active_procs[ num_active ] = active_procs[ num_active - 1 ];
828 active_handles[ num_active - 1 ] = completed_event;
829 active_procs[ num_active - 1 ] = -1;
830 ++num_active;
831 }
832 else if ( ( completed_event != INVALID_HANDLE_VALUE ) &&
833 !((num_active + 1) % MAXIMUM_WAIT_OBJECTS) )
834 {
835 active_handles[ num_active ] = completed_event;
836 active_procs[ num_active ] = -1;
837 ++num_active;
838 }
839 active_handles[ num_active ] = cmdtab[ i ].pi.hProcess;
840 active_procs[ num_active ] = i;
841 ++num_active;
842 }
843
844 assert( (num_active <= MAXIMUM_WAIT_OBJECTS) ==
845 (completed_event == INVALID_HANDLE_VALUE) );
846 if ( num_active <= MAXIMUM_WAIT_OBJECTS )
847 {
848 twh_params twh;
849 twh.active_procs = active_procs;
850 twh.active_handles = active_handles;
851 twh.num_active = num_active;

Callers 1

exec_waitFunction · 0.85

Calls 1

try_wait_helperFunction · 0.85

Tested by

no test coverage detected