📄 月光软件站 - 编程文档 - vc语言 - 一个好用的线程池.mht
字号:
// SD<BR> =20
=
0,  =
; =20
// initial stack =
size<BR> =20
(LPTHREAD_START_ROUTINE)WorkerProc, // =
thread=20
function<BR> =20
=
(LPVOID)this, =
=
// thread =
argument<BR> =20
=
0,  =
; =20
// creation =
option<BR> =20
&nThreadId ); =20
<BR> ReportDebug("generate a worker thread handle =
id is=20
%d.\n",=20
=
nThreadId);<BR> m_threadMap.insert(m_threadMap.end(),ThreadInf=
oMap::value_type(nThreadId,ThreadInfo(hThread,=20
false)));<BR> }<BR>}</P>
<P>void CThreadPoolImp::RemoveThread(DWORD=20
threadId)<BR>{<BR> CAutoLock=20
=
lock(m_arrayCs);<BR> m_threadMap.erase(threadId);<BR>}</P>
<P>void =
CThreadPoolImp::RemoveThreads()<BR>{<BR> unsigned int=20
nCount=3Dm_threadMap.size();<BR> unsigned int=20
nTotal=3Dmax(nCount-2,=20
m_nNumberOfStaticThreads);<BR> for(unsigned int i=3D0;=20
i<nCount-nTotal;=20
=
i++)<BR> {<BR> ::PostQueuedCompletionStatus(m_hWorkerIoPo=
rt,=20
0, 0, (OVERLAPPED*)0xFFFFFFFE);<BR> }<BR>}</P>
<P>CThreadPoolImp::ThreadPoolStatus=20
CThreadPoolImp::GetThreadPoolStatus()<BR>{<BR> int =
nTotal =3D=20
m_threadMap.size();<BR> ThreadInfo info;<BR> int=20
nCount=3D0;<BR> Iterator_ThreadInfoMap =
i=3Dm_threadMap.begin();=20
=
<BR> while(i!=3Dm_threadMap.end())<BR> {<BR> info=3D=
i->second;<BR> if=20
(info.m_bBusyWorking=3D=3Dtrue)=20
nCount++;<BR> i++;<BR> }<BR> if (=20
nCount/(1.0*nTotal) > 0.8 )<BR> return=20
BUSY;<BR> if ( nCount/ (1.0*nTotal) < 0.2=20
)<BR> return IDLE;<BR> return =
NORMAL;<BR>}</P>
<P><BR> </P><IMG height=3D1=20
=
src=3D"http://www.moon-soft.com/doc/down_info.asp?id=3D34506" width=3D1=20
border=3D0><BR><BR></TD></TR>
<TR>
<TD width=3D"100%" bgColor=3D#cccccc height=3D1></TD></TR>
<TR>
<TD width=3D"100%"><BR><B>=CF=E0=B9=D8=CE=C4=D5=C2</B>=A3=BA
=
<P><B>=CF=E0=B9=D8=C8=ED=BC=FE</B>=A3=BA</P></TD></TR></TBODY></TABLE></T=
D></TR></TBODY></TABLE></CENTER></DIV>
<CENTER>
<SCRIPT src=3D"http://www.moon-soft.com/bottom.js" =
type=3Dtext/javascript></SCRIPT>
</CENTER><BR><BR><BR>
<DIV align=3Dcenter>
<CENTER>
<TABLE style=3D"FONT-SIZE: 9pt" cellSpacing=3D0 cellPadding=3D1 =
width=3D770 border=3D0>
<TBODY>
<TR>
<TD width=3D770 bgColor=3D#000000 height=3D1></TD></TR>
<TR>
<TD width=3D770 height=3D5></TD></TR>
<TR>
<TD align=3Dmiddle width=3D770><A href=3D"http://www.moon-soft.com/" =
target=3D_top>=D4=C2=B9=E2=C8=ED=BC=FE</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/download/"=20
target=3D_top>=B3=CC=D0=F2=CF=C2=D4=D8</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/doc/"=20
target=3D_top>=B1=E0=B3=CC=CE=C4=B5=B5</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/book/"=20
target=3D_top>=B5=E7=C4=D4=BD=CC=B3=CC</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/web/"=20
target=3D_top>=CD=F8=D5=BE=C9=E8=BC=C6</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/site/"=20
target=3D_top>=CD=F8=D6=B7=B5=BC=BA=BD</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/art/"=20
target=3D_top>=CD=F8=C2=E7=CE=C4=D1=A7</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/game/"=20
target=3D_top>=D3=CE=CF=B7=CC=EC=B5=D8</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/joke/"=20
target=3D_top>=D3=C4=C4=AC=D0=A6=BB=B0</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/life/"=20
target=3D_top>=C9=FA=BB=EE=D0=DD=CF=D0</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/picture/"=20
target=3D_top>=C3=C0=C5=AE=CD=BC=C6=AC</A>=A9=AE<A =
href=3D"http://www.moon-soft.com/guestbook/"=20
target=3D_top>=D2=E2=BC=FB=B7=B4=C0=A1</A><BR><A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite1105.htm">=B5=E7=C4=D4=
=BC=BC=CA=F5</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite405353.htm">=B1=E0=B3=
=CC=BF=AA=B7=A2</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite25188.htm">=CD=F8=C2=
=E7=D7=A8=C7=F8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite10811.htm">=CC=B8=CC=
=EC=CB=B5=B5=D8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite113108.htm">=C7=E9=B8=
=D0=CA=C0=BD=E7</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872697.htm">=D3=CE=CF=
=B7=D4=AA=CB=D8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite50820.htm">=B7=D6=C0=
=E0=D3=CE=CF=B7</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite166458.htm">=C8=C8=C3=
=C5=D3=CE=CF=B7</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite42994.htm">=CC=E5=D3=
=FD=D4=CB=B6=AF</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872698.htm">=CA=D6=BB=
=FA=D7=A8=C7=F8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite28075.htm">=D2=B5=D3=
=E0=B0=AE=BA=C3</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite34403.htm">=D3=B0=CA=
=D3=C9=B3=C1=FA</A><BR><A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872701.htm">=D2=F4=C0=
=D6=CC=EC=B5=D8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872702.htm">=CA=FD=C2=
=EB=B9=E3=B3=A1</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite121902.htm">=BD=CC=D3=
=FD=D4=B0=B5=D8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872703.htm">=BF=C6=D1=
=A7=B4=F3=B9=DB</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite991826.htm">=B9=C5=BD=
=F1=D7=DD=BA=E1</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite49868.htm">=CC=B8=B9=
=C9=C2=DB=BD=F0</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite55064.htm">=C8=CB=CE=
=C4=D2=D5=CA=F5</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite165391.htm">=D2=BD=D1=
=A7=B1=A3=BD=A1</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite115338.htm">=B6=AF=C2=
=FE=CD=BC=BF=E1</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite872704.htm">=B6=FE=CA=
=D6=D7=A8=C7=F8</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite112364.htm">=B5=D8=B7=
=BD=B7=E7=C7=E9</A>=A9=AE<A=20
=
href=3D"http://www.moon-soft.com/program/bbs/docelite165368.htm">=B8=F7=D0=
=D0=B8=F7=D2=B5</A><BR><BR><A=20
=
href=3D"http://www.moon-soft.com/">=D4=C2=B9=E2=C8=ED=BC=FE=D5=BE</A>=A1=A4=
<A=20
href=3D"http://www.moon-soft.com/sitemap.htm" =
target=3D_blank>=B0=E6=C8=A8=CB=F9=D3=D0</A>=20
</TD></TR></TBODY></TABLE></CENTER></DIV>
<SCRIPT src=3D"http://www.moon-soft.com/program/bbs/bottom.js"=20
type=3Dtext/javascript></SCRIPT>
<DIV id=3Dobjbottom align=3Dcenter>
<CENTER>
<SCRIPT type=3Dtext/javascript>=20
cpro_client=3D'williamlongcpr';
cpro_cbd=3D'#trans';=20
cpro_cbg=3D'#trans';=20
cpro_ctitle=3D'#000000';=20
cpro_cdesc=3D'#444444';=20
cpro_curl=3D'#333333';=20
cpro_clink=3D'#000000';=20
cpro_flush=3D4;=20
cpro_w=3D760;=20
cpro_h=3D90;=20
cpro_template=3D'text_default_760_90';=20
</SCRIPT>
<SCRIPT language=3DJavaScript =
src=3D"http://cpro.baidu.com/cpro/ui/cp.js"=20
type=3Dtext/javascript></SCRIPT>
</CENTER></DIV>
<SCRIPT language=3Djavascript>
if(document.all.item("objtop") !=3D null)
{
objtop.innerHTML =3D objbottom.innerHTML
}
</SCRIPT>
<SCRIPT src=3D"http://www.google-analytics.com/urchin.js" =
type=3Dtext/javascript>
</SCRIPT>
<SCRIPT type=3Dtext/javascript>
_uacct =3D "UA-272027-6";
urchinTracker();
</SCRIPT>
<SCRIPT language=3Djavascript=20
src=3D"http://utk.baidu.com/usv/uc.sv?pe=3DRlkGH7bxlqIfB1CURpxOo8rMCFCj6I=
24cSk=3D&sn=3D208&an=3D43125&rn=3D332"></SCRIPT>
<BR><BR><BR><BR><BR><BR><!-- */ //--></BODY></HTML>
------=_NextPart_000_004D_01C8156E.BE684730
Content-Type: image/gif
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.moon-soft.com/doc/images/d_1.gif
GIF89a=0D=00=0D=00=91=00=00X=A6=EF=FF=FF=FF=9C=9C=9C=00=00=00,=00=00=00=00=
=0D=00=0D=00=00=02"=94=8F=08=CB=0D!=9C=84.=84F=EB]Y=F3h=85=E2=13M[=C7Xi=99=
n=9FT=B10)=D6a=01=00;
<br><br><br>
<div align=3D"center"><center>
<table cellspacing=3D"0" cellpadding=3D"1" border=3D"0" width=3D"770" =
style=3D"font-size: 9pt;" >
<tr><td width=3D"770" bgcolor=3D"#000000" height=3D"1"></td></tr>
<tr><td width=3D"770" height=3D"5"></td></tr>
<tr>
<td align=3D"center" width=3D"770">
<a href=3D"/" target=3D"_top">=D4=C2=B9=E2=C8=ED=BC=FE</a>=A9=AE<a =
href=3D"/download/" target=3D"_top">=B3=CC=D0=F2=CF=C2=D4=D8</a>=A9=AE<a =
href=3D"/doc/" target=3D"_top">=B1=E0=B3=CC=CE=C4=B5=B5</a>=A9=AE<a =
href=3D"/book/" target=3D"_top">=B5=E7=C4=D4=BD=CC=B3=CC</a>=A9=AE<a =
href=3D"/web/" target=3D"_top">=CD=F8=D5=BE=C9=E8=BC=C6</a>=A9=AE<a =
href=3D"/site/" target=3D"_top">=CD=F8=D6=B7=B5=BC=BA=BD</a>=A9=AE<a =
href=3D"/art/" target=3D"_top">=CD=F8=C2=E7=CE=C4=D1=A7</a>=A9=AE<a =
href=3D"/game/" target=3D"_top">=D3=CE=CF=B7=CC=EC=B5=D8</a>=A9=AE<a =
href=3D"/joke/" target=3D"_top">=D3=C4=C4=AC=D0=A6=BB=B0</a>=A9=AE<a =
href=3D"/life/" target=3D"_top">=C9=FA=BB=EE=D0=DD=CF=D0</a>=A9=AE<a =
href=3D"/picture/" target=3D"_top">=C3=C0=C5=AE=CD=BC=C6=AC</a>=A9=AE<a =
href=3D"/guestbook/" target=3D"_top">=D2=E2=BC=FB=B7=B4=C0=A1</a><br>
<a =
href=3D"/program/bbs/docelite1105.htm">=B5=E7=C4=D4=BC=BC=CA=F5</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite405353.htm">=B1=E0=B3=CC=BF=AA=B7=A2</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite25188.htm">=CD=F8=C2=E7=D7=A8=C7=F8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite10811.htm">=CC=B8=CC=EC=CB=B5=B5=D8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite113108.htm">=C7=E9=B8=D0=CA=C0=BD=E7</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite872697.htm">=D3=CE=CF=B7=D4=AA=CB=D8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite50820.htm">=B7=D6=C0=E0=D3=CE=CF=B7</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite166458.htm">=C8=C8=C3=C5=D3=CE=CF=B7</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite42994.htm">=CC=E5=D3=FD=D4=CB=B6=AF</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite872698.htm">=CA=D6=BB=FA=D7=A8=C7=F8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite28075.htm">=D2=B5=D3=E0=B0=AE=BA=C3</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite34403.htm">=D3=B0=CA=D3=C9=B3=C1=FA</a><br>
<a =
href=3D"/program/bbs/docelite872701.htm">=D2=F4=C0=D6=CC=EC=B5=D8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite872702.htm">=CA=FD=C2=EB=B9=E3=B3=A1</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite121902.htm">=BD=CC=D3=FD=D4=B0=B5=D8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite872703.htm">=BF=C6=D1=A7=B4=F3=B9=DB</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite991826.htm">=B9=C5=BD=F1=D7=DD=BA=E1</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite49868.htm">=CC=B8=B9=C9=C2=DB=BD=F0</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite55064.htm">=C8=CB=CE=C4=D2=D5=CA=F5</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite165391.htm">=D2=BD=D1=A7=B1=A3=BD=A1</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite115338.htm">=B6=AF=C2=FE=CD=BC=BF=E1</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite872704.htm">=B6=FE=CA=D6=D7=A8=C7=F8</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite112364.htm">=B5=D8=B7=BD=B7=E7=C7=E9</a>=A9=AE=
<a =
href=3D"/program/bbs/docelite165368.htm">=B8=F7=D0=D0=B8=F7=D2=B5</a><br>=
<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -