Semi pseudo-code:
Code: Select all
Procedure AddToResponseQueue(fastCgiHandle.l)
; Stores handle in a global map
EndProcedure
Procedure ProcessWaitingQueue()
; Pull next waiting request out of the queue
handle.l = GetWaitingRequestHandle()
; Perform any db queries / other time intensive work etc
; Respond!
WriteCGIString(handle.l, "Response")
FinishFastCGIRequest()
EndProcedure
CreateThread(@ProcessWaitingQueue(), 0)
While WaitFastCGIRequest()
handle.l = ReadCGI()
AddToResponseQueue( handle )
Wend