tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Threads_Manager

Source Location: /web_site/threads_manager.class.php

Class Threads_Manager

Class Overview

Threads Manager

Threads concept is enhancement over sessions. Sites that implements threads management can detect when new instance of browser is opened and user is working with two or more browsers simultaneously. Threads manager function is to detect such "forks" and to split dataspace for the treads so each tread to have separate dataspace. This class is not ment to be used directly by the users - quite the opposite - it is ment to be 100% transparent. User have to use Web_Site/Web_Page get_tvm methods in order to get TVM.

Located in /web_site/threads_manager.class.php [line 50]

Tangra_Class
   |
   --Threads_Manager
Author(s):
API Tags:
See:  Thread_Vars_Manager

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Constant Summary
MAX_SNAPSHOTS   Default maximum count of snapshots. Intended to prevend DoS attacks
SNAPSHOTS_DEFAULT_LIFETIME   Default lifetime for snapshots

[ Top ]
Property Summary
integer   $current_thread_index   Index of current thread
string   $current_url_var   Current URL variable (thread "id")
integer   $max_snapshots   Maximum count of snapshots.
array   $next_snapshot_index   Holds next unused snapshot index per thread
integer   $next_thread_index   Holds next unused thread index
integer   $snapshots_lifetime   Lifetime for snapshots in seconds
mixed   $threads   Array that contain all existing threads
array   $threads_snapshots   Snapshots of threads
string   $url_rewrite_var_name   name that will be used for the variable that will hold thread "id"
array   $url_var_to_thread_links   Array that contain map url vars to thread index

[ Top ]
Method Summary
Threads_Manager   __construct()   Constructor
integer   add_new_thread()   Adds new thread
integer   add_snapshot()   Adds snapshot for thread specified by $thread_num
void   collect_garbage()   Colects garbage snapshots
void   count_snapshots()  
void   create_new_thread()   Creates new thread
integer   generate_new_random()   Generates random number
integer   get_current_thread_index()   Returns current thread index
Vars_Manager   &get_current_thread_vm()   Returns reference to current thread Vars_Manager
unknown   get_current_url_var()   Returns current URL variable value
string   get_new_url_var()   Generates new value for URL rewrite variable
array   get_snapshot()   Returns snapshot of thread
integer   get_snapshots_lifetime()   Returns lifetime setting for snapshots
string   get_url_rewrite_var()   Returns value of passed URL rewrite variable
unknown   get_url_rewrite_var_name()   Returns URL variable name
unknown   get_usage_stat()   Returns statistic about usage of threads and snapshots.
boolean   is_url_rewrite_var_passed()   Checks if URL variable is passed in POST or GET
void   move_snapshot()   Moves snapshot from one thread to another.
void   new_pass()   Prepares ovject for new process
void   process()   Processes current context and manages threads
void   remove_url_var_to_thread_link()   Removes url_var_to_thread_link for given snapshot
void   reset()  
void   save_snapshot()   Saves snapshot ot current thread
void   snapshot_update_access_time()   Updates last access time of current (detected from context) snapshot

[ Top ]
Properties
integer   $current_thread_index [line 90]

Index of current thread

API Tags:
Internal:  
Access:  private


[ Top ]
string   $current_url_var [line 97]

Current URL variable (thread "id")

API Tags:
Internal:  
Access:  private


[ Top ]
integer   $max_snapshots [line 119]

Maximum count of snapshots.

API Tags:
Access:  private


[ Top ]
array   $next_snapshot_index = array() [line 133]

Holds next unused snapshot index per thread

API Tags:
Access:  private


[ Top ]
integer   $next_thread_index = 0 [line 126]

Holds next unused thread index

API Tags:
Access:  private


[ Top ]
integer   $snapshots_lifetime [line 112]

Lifetime for snapshots in seconds

API Tags:
Access:  private


[ Top ]
mixed   $threads = array() [line 76]

Array that contain all existing threads

API Tags:
Internal:  
Access:  private


[ Top ]
array   $threads_snapshots = array() [line 105]

Snapshots of threads

API Tags:
Internal:  
Access:  private


[ Top ]
string   $url_rewrite_var_name [line 69]

name that will be used for the variable that will hold thread "id"

API Tags:
Internal:  
Access:  private


[ Top ]
array   $url_var_to_thread_links = array() [line 83]

Array that contain map url vars to thread index

API Tags:
Internal:  
Access:  private


[ Top ]
Methods
Constructor __construct  [line 141]

  Threads_Manager __construct( unknown_type $url_rewrite_var_name, [unknown_type $snapshots_lifetime = Threads_Manager::SNAPSHOTS_DEFAULT_LIFETIME], [ $max_snapshots = Threads_Manager::MAX_SNAPSHOTS]  )

Constructor

Parameters:
unknown_type   $url_rewrite_var_name:  Name for the URL variable that will be used to track threads
unknown_type   $snapshots_lifetime:  Number of seconds after which snapshot will be seen as garbage and eventually unset
   $max_snapshots: 


[ Top ]
add_new_thread  [line 420]

  integer add_new_thread( )

Adds new thread


API Tags:
Return:  Index of the new thread
Internal:  
Access:  private


[ Top ]
add_snapshot  [line 287]

  integer add_snapshot( integer $thread_num  )

Adds snapshot for thread specified by $thread_num

Parameters:
integer   $thread_num:  thread index

API Tags:
Return:  Snapshot index
Internal:  
Access:  private


[ Top ]
collect_garbage  [line 460]

  void collect_garbage( )

Colects garbage snapshots


API Tags:
Internal:  
Access:  private


[ Top ]
count_snapshots  [line 311]

  void count_snapshots( )


API Tags:
Access:  private


[ Top ]
create_new_thread  [line 227]

  void create_new_thread( )

Creates new thread


API Tags:
Internal:  
Access:  private


[ Top ]
generate_new_random  [line 435]

  integer generate_new_random( )

Generates random number


API Tags:
Internal:  
Access:  private


[ Top ]
get_current_thread_index  [line 347]

  integer get_current_thread_index( )

Returns current thread index


API Tags:
Access:  public


[ Top ]
get_current_thread_vm  [line 377]

  Vars_Manager &get_current_thread_vm( )

Returns reference to current thread Vars_Manager


API Tags:
Access:  public


[ Top ]
get_current_url_var  [line 357]

  unknown get_current_url_var( )

Returns current URL variable value


API Tags:
Access:  public


[ Top ]
get_new_url_var  [line 447]

  string get_new_url_var( )

Generates new value for URL rewrite variable


API Tags:
Internal:  
Access:  private


[ Top ]
get_snapshot  [line 330]

  array get_snapshot( integer $thread_num, unknown_type $snapshot_num  )

Returns snapshot of thread

Parameters:
integer   $thread_num:  thread index
unknown_type   $snapshot_num:  Snapshot index

API Tags:
Internal:  
Access:  private


[ Top ]
get_snapshots_lifetime  [line 217]

  integer get_snapshots_lifetime( )

Returns lifetime setting for snapshots


API Tags:
Return:  Lifetime in seconds
Access:  public


[ Top ]
get_url_rewrite_var  [line 402]

  string get_url_rewrite_var( Web_Context $context  )

Returns value of passed URL rewrite variable

Parameters:
Web_Context   $context: 

API Tags:
Internal:  
Access:  private


[ Top ]
get_url_rewrite_var_name  [line 367]

  unknown get_url_rewrite_var_name( )

Returns URL variable name


API Tags:
Access:  public


[ Top ]
get_usage_stat  [line 505]

  unknown get_usage_stat( )

Returns statistic about usage of threads and snapshots.


API Tags:
Access:  public


[ Top ]
is_url_rewrite_var_passed  [line 389]

  boolean is_url_rewrite_var_passed( Web_Context $context  )

Checks if URL variable is passed in POST or GET

Parameters:
Web_Context   $context: 

API Tags:
Internal:  
Access:  private


[ Top ]
move_snapshot  [line 257]

  void move_snapshot( integer $old_threat_index, integer $snapshot_index, integer $new_thread_index, string $url_var  )

Moves snapshot from one thread to another.

Parameters:
integer   $old_threat_index: 
integer   $snapshot_index: 
integer   $new_thread_index: 
string   $url_var: 

API Tags:
Internal:  
Access:  private


[ Top ]
new_pass  [line 274]

  void new_pass( )

Prepares ovject for new process


API Tags:
Internal:  
Access:  private


[ Top ]
process  [line 153]

  void process( Web_Context $context  )

Processes current context and manages threads

Parameters:
Web_Context   $context: 

API Tags:
Access:  public


[ Top ]
remove_url_var_to_thread_link  [line 489]

  void remove_url_var_to_thread_link( integer $thread_index, integer $snapshot_index  )

Removes url_var_to_thread_link for given snapshot

Parameters:
integer   $thread_index: 
integer   $snapshot_index: 

API Tags:
Internal:  
Access:  private


[ Top ]
reset  [line 516]

  void reset( )


API Tags:
Access:  public


[ Top ]
save_snapshot  [line 236]

  void save_snapshot( )

Saves snapshot ot current thread


API Tags:
Access:  public


[ Top ]
snapshot_update_access_time  [line 194]

  void snapshot_update_access_time( Web_Context $context  )

Updates last access time of current (detected from context) snapshot

Parameters:
Web_Context   $context: 

API Tags:
Access:  public


[ Top ]
Constants
MAX_SNAPSHOTS = 250 [line 61]

Default maximum count of snapshots. Intended to prevend DoS attacks


[ Top ]
SNAPSHOTS_DEFAULT_LIFETIME = 300 [line 55]

Default lifetime for snapshots


[ Top ]