Recent

Author Topic: Thread or instance in fcgi model  (Read 1650 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1273
Thread or instance in fcgi model
« on: March 26, 2018, 08:28:26 am »
Hi,

I'm developing a web server using FastCGI model on MS Windows. My question is regarding accessing a variable. Specifically let's assume that I define variables like followings.

Code: Pascal  [Select][+][-]
  1. interface
  2.  
  3. type
  4.  
  5. TwmDC1 = class(TFPWebModule)  
  6. public
  7.    var1 : integer;
  8. end;
  9.  
  10. var
  11.     var2: integer;


In this case, if there are more than two accesses (requests) from browsers at the same time, are var1 and var2 shared by the requests or not? Why are they shared or not? Is it related with thread or instance?

Regards,

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Thread or instance in fcgi model
« Reply #1 on: March 26, 2018, 12:06:03 pm »
This depends on the value of Kind property, if wkOneShot, a module lifetime is per request. Otherwise, it's created once and live for as long as application lives (shared instance, so concurrent requests are handled by the same instance -> module variable values are shared -> take care of the concurrent access yourself).
« Last Edit: March 26, 2018, 12:09:36 pm by Leledumbo »

 

TinyPortal © 2005-2018