This code fragment illustrates the use of srv_sleep in preemptive mode:
/*
** Request the mutex to prevent the logging service
** from calling srv_wakeup before srv_sleep is called.
*/
if (WaitForSingleObject(Mutex,INFINITE) != WAIT_OBJECT_0)
return(CS_FAIL);
/*
** Send the log_request to the logging service.
*/
if (srv_putmsgq(log_service,log_request, SRV_M_NOWAIT) == CS_FAIL)
return(CS_FAIL);
/*
** Sleep until the log service has processed the log request.
*/
srv_sleep(log_request, LOGWAIT, NULL, NULL, (CS_VOID*)Mutex, (CS_VOID*)0);
/*
** Return the log sequence number to the caller.
*/
return(CS_SUCCEED);