FastCGI multiplexing

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
greyhoundcode
Enthusiast
Enthusiast
Posts: 112
Joined: Sun Dec 30, 2007 7:24 pm

FastCGI multiplexing

Post by greyhoundcode »

Right now PB's FastCGI implementation supports threading, which is great. I'm wondering though - if this is viable - if support for handling multiple requests 'concurrently' without creating a new thread per request could be added?

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
So yes, I'm using threading, but I may essentially have a single thread putting together the responses (and still want to accept new incoming requests). I basically want to multiplex between them, and have request handles to facilitate that.
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: FastCGI multiplexing

Post by Poshu »

*bump*

Same here : request handle would allow me to speed up my server considerably.
Post Reply