| 项目搜索 |
| |
|
代码片段库:
查看代码片段
浏览
| 提交新的代码片段
| 创建代码包
Toggling Checkboxes
|
类型:
Function |
类别:
Other
|
许可证:
GNU General Public License |
语言:
Visual Basic
|
描述:
This is mutex problem, arising in huge websites, where a lot of information for each session user has to be unique. IHere the solution of mutex problem using web technology ASP. The same logic can be implemented in others technology also. Or even this can be implemented in client server application. For any bugs or enquiry please give me a mail at [email protected]. All the best.
|
该代码片段的版本系列:
片段ID |
下载版本 |
提交时间 |
提交人 |
删除 |
4837 | 1.0 | 2003-12-17 23:15 | cbd001 | |
点击"下载版本"来下载该代码片段.
最新版本的代码片段: 1.0
'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP
There are two files, global.asa, and index.asp. Create a directory, place there two files, then create virtualdirectory, and execute the program with 15000 user at a time. You can get 100% acuurate value.
FILE GLOBAL.ASA
---------------
<SCRIPT LANGUAGE='VBScript' RUNAT=SERVER>
'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP
function GetNewId()
if Application("ent") = false then 'Before enter first check
if Application("work") = false then 'By time, if more than one user enter in this case, but only one user will be able to enter in next loop, all others have to wait
Application("work") = true ' NOw lock the allication variables and work; You may also do ur others work here like table update or anythings
Application.Lock
Application("recordsid") = Application("recordsid") + 1
Application.UnLock
Application("work") = false 'When every things is done realeased the variable lock, and let others user in the queue can enter in this loop
Application("ent") = false
Session("status")=true
else
Application("ent") = false 'In this case one user allready working, so lets return
Session("status") = false
End if
else
Session("status") = false 'No hope allready entering in first chanme, wait untill completed
end if
End function
SUB Application_OnStart
Application("ent") = false
Application("work") = false
Application("recordsid") = 0
END SUB
SUB Session_OnStart
Session.TimeOut = 20 ' You change this variable according your need
Session("status")=false ' By defalt status is false
Session("ret") = GetNewId() 'First call the function and the return values is save in session variables
while Session("status") = false ' Now in this while loops checks whether the return is tru or false, if it is false call the function untill it is true
Session("ret") = GetNewId()
wend
END SUB
</SCRIPT>
<SCRIPT LANGUAGE='VBScript' RUNAT=SERVER>
SUB Session_OnEnd
END SUB
</SCRIPT>
----------------
FILE INDEX.ASP
-----------------
<%@ Language=VBScript %>
<%
'Copy Right Himadrish Laha
'You can use this code but must use this comment line
'Originally written by- Himadrish Laha <[email protected]>
'For avoid the problem in large websites when thousand of user logs-in and logs-out
'MutexSolutions In ASP
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<P>燭he recorsd id is <font color="blue"><b><%=Application("recordsid")%></b></font><br><br>
For any help mail me at <a href="mailto:[email protected]">[email protected]</a>
</P>
</BODY>
</HTML>
如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来. |
|