⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual.ps

📁 这是我们参加06年全国开源软件的竞赛作品
💻 PS
📖 第 1 页 / 共 5 页
字号:
1495 y(tion,)e(which)f(pro)o(vided)i(a)d(non-blocking)25b(form)c(of)f Fn(sync)p Fq(.)27 b(Instead)22 b(of)f(this)g(operation,)j(CML)664 1608 y(no)n(w)h(pro)o(vides)h(non-blocking)j(input)e(operations)g(on)e(man)o(y)g(of)g(the)g(basic)h(communication)6641721 y(types.)2136 5187 y(2)p eop%%Page: 3 33 2 bop 241 1179 a Ft(Chapter)44 b(2)241 1595 y Fs(Cor)l(e)52b(CML)f(r)l(efer)l(ence)241 2077 y Fr(2.1)119 b(The)30b Fm(CML)f Fr(structur)n(e)241 2405 y Fp(Synopsis:)3612519 y Fl(signature)18 b Fk(CML)361 2632 y Fl(structure)73b Fk(CML:)53 b(CML)241 2866 y Fp(Interface:)361 2966y Fj(type)20 b Fn(thread)p 886 2966 25 4 v 29 w(id)3613066 y Fj(type)g Fi(\013)h Fn(chan)361 3165 y Fj(type)fFi(\013)h Fn(event)361 3265 y Fj(val)15 b Fn(version:)98b Fh(f)p Fn(system)22 b Fg(:)h Fn(string)o Fi(;)k Fn(version)p2138 3265 V 29 w(id)c Fg(:)g Fn(int)f(list)o Fi(;)28b Fn(date)22 b Fg(:)i Fn(string)n Fh(g)361 3365 y Fj(val)cFn(banner:)98 b(string)361 3464 y Fj(val)20 b Fn(spawnc:)98b Fg(\()p Fi(\013)24 b Fh(!)f Fn(unit)o Fg(\))h Fh(!)fFi(\013)g Fh(!)g Fn(thread)p 2042 3464 V 29 w(id)3613564 y Fj(val)d Fn(spawn:)98 b Fg(\()p Fn(unit)23 b Fh(!)gFn(unit)o Fg(\))h Fh(!)f Fn(thread)p 1956 3564 V 29 w(id)3613664 y Fj(val)d Fn(yield:)98 b(unit)23 b Fh(!)g Fn(unit)3613763 y Fj(val)d Fn(exit:)99 b(unit)22 b Fh(!)h Fi(\013)3613863 y Fj(val)d Fn(getTid:)98 b(unit)23 b Fh(!)g Fn(thread)p1613 3863 V 28 w(id)361 3962 y Fj(val)d Fn(sameTid:)98b Fg(\()p Fn(thread)p 1366 3962 V 29 w(id)18 b(*)g(thread)p1881 3962 V 29 w(id)p Fg(\))23 b Fh(!)g Fn(bool)361 4062y Fj(val)d Fn(compareTid:)98 b Fg(\()p Fn(thread)p 15164062 V 29 w(id)18 b(*)g(thread)p 2031 4062 V 29 w(id)oFg(\))24 b Fh(!)f Fn(order)361 4162 y Fj(val)d Fn(hashTid:)98b(thread)p 1334 4162 V 29 w(id)23 b Fh(!)g Fn(word)3614261 y Fj(val)d Fn(tidToString:)97 b(thread)p 1533 4261V 29 w(id)23 b Fh(!)g Fn(string)361 4361 y Fj(val)d Fn(joinEvt:)98b(thread)p 1334 4361 V 29 w(id)23 b Fh(!)g Fn(unit)f(event)3614461 y Fj(val)e Fn(channel:)98 b(unit)22 b Fh(!)h Fi(\013)cFn(chan)361 4560 y Fj(val)h Fn(sameChannel:)97 b Fg(\()pFi(\013)19 b Fn(chan)f(*)g Fi(\013)h Fn(chan)p Fg(\))kFh(!)g Fn(bool)361 4660 y Fj(val)d Fn(send:)99 b Fg(\()pFi(\013)19 b Fn(chan)f(*)g Fi(\013)p Fg(\))24 b Fh(!)fFn(unit)361 4759 y Fj(val)d Fn(recv:)99 b Fi(\013)19b Fn(chan)j Fh(!)h Fi(\013)361 4859 y Fj(val)d Fn(sendEvt:)98b Fg(\()p Fi(\013)19 b Fn(chan)f(*)g Fi(\013)p Fg(\))24b Fh(!)f Fn(unit)f(event)361 4959 y Fj(val)e Fn(recvEvt:)98b Fi(\013)19 b Fn(chan)j Fh(!)h Fi(\013)c Fn(event)17125187 y Fq(3)p eop%%Page: 4 44 3 bop 784 555 a Fj(val)20 b Fn(sendPoll:)98 b Fg(\()pFi(\013)19 b Fn(chan)f(*)g Fi(\013)p Fg(\))24 b Fh(!)fFn(bool)784 655 y Fj(val)d Fn(recvPoll:)98 b Fi(\013)19b Fn(chan)j Fh(!)i Fi(\013)18 b Fn(option)784 754 y Fj(val)iFn(wrap:)99 b Fg(\()p Fi(\013)19 b Fn(event)f(*)p Fg(\()pFi(\013)23 b Fh(!)g Fi(\014)t Fg(\)\))h Fh(!)f Fi(\014)gFn(event)784 854 y Fj(val)d Fn(wrapHandler:)98 b Fg(\()pFi(\013)19 b Fn(event)e(*)p Fg(\()p Fn(exn)23 b Fh(!)gFi(\013)c Fn(event)o Fg(\)\))24 b Fh(!)f Fi(\013)c Fn(event)784954 y Fj(val)h Fn(guard:)99 b Fg(\()p Fn(unit)22 b Fh(!)iFi(\013)18 b Fn(event)o Fg(\))24 b Fh(!)f Fi(\013)c Fn(event)7841053 y Fj(val)h Fn(withNack:)98 b Fg(\()p Fn(unit)23b(event)f Fh(!)h Fi(\013)c Fn(event)o Fg(\))k Fh(!)gFi(\013)c Fn(event)784 1153 y Fj(val)h Fn(choose:)99b Fi(\013)19 b Fn(event)j(list)g Fh(!)h Fi(\013)c Fn(event)7841253 y Fj(val)h Fn(sync:)99 b Fi(\013)19 b Fn(event)jFh(!)h Fi(\013)784 1352 y Fj(val)d Fn(select:)99 b Fi(\013)19b Fn(event)j(list)g Fh(!)h Fi(\013)784 1452 y Fj(val)dFn(never:)99 b Fi(\013)19 b Fn(event)784 1551 y Fj(val)hFn(alwaysEvt:)98 b Fi(\013)24 b Fh(!)f Fi(\013)c Fn(event)7841651 y Fj(val)h Fn(timeOutEvt:)98 b(Time)o Fi(:)p Fn(time)23b Fh(!)g Fn(unit)f(event)784 1751 y Fj(val)e Fn(atTimeEvt:)98b(Time)o Fi(:)p Fn(time)23 b Fh(!)g Fn(unit)f(event)6641990 y Fp(Description:)664 2109 y Fl(type)f Fk(thread)p1240 2109 28 4 v 30 w(id)784 2304 y Fq(Thread)33 b(IDs)f(are)h(the)f(unique)i(IDs)e(associated)k(with)c(CML)e(threads.)57b(These)33 b(IDs)f(are)784 2417 y(in)c(an)g(unspeci\002ed)i(total)e(order)h(that)f(can)h(be)e(used)i(to)f(break)h(c)o(yclic)f(depedencies)k(\(see)784 2530 y Fn(compareTid)p Fq(\).)664 2724 yFl(type)21 b Ff(\013)i Fk(chan)784 2919 y Fq(This)h(is)f(the)h(type)g(constructor)j(for)c(synchronous)28 b(channels.)664 3114y Fl(type)21 b Ff(\013)i Fk(event)784 3308 y Fq(Ev)o(ent)28b(v)n(alues)h(are)f(abstract)h(representations)j(of)c(synchronous)j(operations)g(\(so)d(called)784 3421 y Fe(\002r)o(st-class)f(syc)o(hr)l(onous)f(oper)o(ations)p Fq(\).)664 3616 y Fl(val)j Fk(version:)106b Fd(f)p Fk(system)37 b Fc(:)j Fk(string)n Ff(;)30 bFk(version)p 2654 3616 V 30 w(id)39 b Fc(:)h Fk(int)e(list)nFf(;)31 b Fk(date)38 b Fc(:)784 3729 y Fk(string)m Fd(g)6643842 y Fl(val)22 b Fk(banner:)105 b(string)784 4036 yFq(These)24 b(specify)h(the)f(v)o(ersion)h(of)f(CML)d(in)j(the)g(same)f(format)h(as)g(SML/NJ.)664 4231 y Fl(val)e Fk(spawnc:)105b Fc(\()p Ff(\013)27 b Fd(!)e Fk(unit)n Fc(\))g Fd(!)hFf(\013)f Fd(!)h Fk(thread)p 2507 4231 V 30 w(id)6644344 y Fl(val)c Fk(spawn:)106 b Fc(\()p Fk(unit)24 bFd(!)h Fk(unit)n Fc(\))h Fd(!)f Fk(thread)p 2412 4344V 30 w(id)784 4538 y Fn(spawnc)49 b Fb(f)55 b(x)784 4651y Fn(spawn)49 b Fb(f)84 b Fq(creates)32 b(a)e(ne)n(w)g(thread)i(of)e(control)i(to)e(e)n(v)n(aluate)i(the)f(body)g(of)f Fb(f)5b Fq(.)49 b(A)29 b(ne)n(w)784 4764 y(unique)c(ID)e(for)h(the)g(thread)g(is)g(created)h(and)f(returned.)664 4959 y Fl(val)e Fk(yield:)106b(unit)23 b Fd(!)i Fk(unit)2136 5187 y Fq(4)p eop%%Page: 5 55 4 bop 361 555 a Fq(This)23 b(function)k(can)d(be)g(used)h(to)e(implement)i(an)f(e)o(xplicit)i(conte)o(xt)f(switch.)30b(Since)25 b(CML)361 668 y(is)31 b(preempti)n(v)o(ely)k(scheduled,)h(it)c(should)h(ne)n(v)o(er)g(be)e(necessary)k(for)d(user)g(programs)i(to)361 781 y(call)24 b(this)g(function.)31 b(It)23 b(is)g(mainly)i(used)f(for)g(performance)i(measurements.)241 953 y Fl(val)21b Fk(exit:)107 b(unit)23 b Fd(!)j Ff(\013)361 1126 yFn(exit)49 b(\(\))72 b Fq(causes)25 b(the)f(calling)h(thread)g(to)e(terminate.)241 1298 y Fl(val)e Fk(getTid:)106 b(unit)23b Fd(!)j Fk(thread)p 1613 1298 28 4 v 30 w(id)361 1470y Fn(getTid)48 b(\(\))73 b Fq(returns)25 b(the)f(thread)h(ID)d(of)i(the)f(calling)j(thread.)241 1643 y Fl(val)21 b Fk(sameTid:)106b Fc(\()p Fk(thread)p 1343 1643 V 30 w(id)19 b(*)h(thread)p1907 1643 V 30 w(id)o Fc(\))26 b Fd(!)f Fk(bool)361 1815y Fn(sameTid)48 b(\()p Fb(tid1)o Fn(,)i Fb(tid2)o Fn(\))70b Fq(returns)22 b(true,)f(if)g(the)f(tw)o(o)h(thread)h(IDs)e(are)g(the)h(same)g(ID.)241 1987 y Fl(val)g Fk(compareTid:)104 bFc(\()p Fk(thread)p 1506 1987 V 31 w(id)19 b(*)h(thread)p2071 1987 V 30 w(id)o Fc(\))25 b Fd(!)g Fk(order)3612160 y Fn(compareTid)48 b(\()p Fb(tid1)o Fn(,)h Fb(tid2)pFn(\))70 b Fq(compares)24 b(the)e(tw)o(o)g(thread)h(IDs)f(and)g(returns)i(their)361 2273 y(order)g(in)f(the)g(total)h(ordering)i(of)d(thread)h(IDs.)k(The)23 b(precise)i(semantics)g(of)e(this)h(ordering)361 2386 y(is)f(left)h(unspeci\002ed,)i(other)e(than)g(to)g(say)g(it)f(is)g(a)g(total)i(order)-5 b(.)241 2558 y Fl(val)21 bFk(hashTid:)106 b(thread)p 1308 2558 V 30 w(id)24 b Fd(!)hFk(word)361 2730 y Fn(hashTid)48 b Fb(tid)76 b Fq(returns)25b(a)e(hashing)i(of)f(the)g(thread)h(ID)d Fb(tid)s Fq(.)2412903 y Fl(val)f Fk(tidToString:)104 b(thread)p 1526 2903V 30 w(id)24 b Fd(!)h Fk(string)361 3075 y Fn(tidToString)48b Fb(tid)75 b Fq(returns)25 b(a)e(string)i(representation)j(of)23b(the)h(thread)h(ID)d Fb(tid)s Fq(.)241 3247 y Fl(val)fFk(joinEvt:)106 b(thread)p 1308 3247 V 30 w(id)24 b Fd(!)hFk(unit)f(event)361 3420 y Fn(joinEvt)48 b Fb(tid)86b Fq(creates)36 b(an)e(e)n(v)o(ent)g(v)n(alue)h(for)g(synchronizing)j(on)c(the)g(termination)361 3532 y(of)29 b(the)g(thread)h(with)f(the)g(ID)f Fb(tid)s Fq(.)44 b(There)29 b(are)g(three)h(w)o(ays)f(that)g(a)f(thread)j(may)d(termi-)361 3645 y(nate:)38 b(the)29 b(function)h(that)e(w)o(as)g(passed)h(to)f Fn(spawn)e Fq(may)i(return;)j(it)d(may)g(call)g(the)g Fn(exit)361 3758 y Fq(function,)k(or)d(it)f(may)h(ha)n(v)o(e)g(an)g(uncaught)i(e)o(xception.)47 b(Note)29 b(that)gFn(joinEvt)e Fq(does)i(not)361 3871 y(distinguish)g(between)f(these)f(cases;)i(it)e(also)g(does)g(not)g(become)g(enabled)h(if)f(the)f(named)361 3984 y(thread)f(deadlocks)h(\(e)n(v)o(en)e(if)f(it)g(is)h(garbage)h(collected\).)241 4156 y Fl(val)c Fk(channel:)106 b(unit)23b Fd(!)i Ff(\013)c Fk(chan)361 4329 y Fn(channel)48 b(\(\))72b Fq(creates)26 b(a)d(ne)n(w)g(synchronous)k(channel.)2414501 y Fl(val)21 b Fk(sameChannel:)104 b Fc(\()p Ff(\013)21b Fk(chan)d(*)i Ff(\013)h Fk(chan)n Fc(\))k Fd(!)h Fk(bool)3614673 y Fn(sameChannel)48 b(\()p Fb(ch1)o Fn(,)h Fb(ch2)pFn(\))80 b Fq(returns)33 b(true,)h(if)d(the)h(tw)o(o)f(channels)i(are)f(the)g(same)361 4786 y(channel.)241 4959 y Fl(val)21b Fk(send:)107 b Fc(\()p Ff(\013)21 b Fk(chan)d(*)i Ff(\013)pFc(\))26 b Fd(!)f Fk(unit)1712 5187 y Fq(5)p eop%%Page: 6 66 5 bop 784 555 a Fn(send)49 b(\()p Fb(ch)p Fn(,)g Fb(a)pFn(\))80 b Fq(sends)32 b(the)f(message)i Fb(a)d Fq(on)h(the)g(synchronous)k(channel)d Fb(ch)p Fq(.)50 b(This)784 668y(operation)37 b(blocks)e(the)f(calling)i(thread)f(until)g(there)g(is)f(another)h(thread)h(attempting)g(a)784 781 y Fn(recv)22b Fq(operation)k(on)e(the)g(channel)h Fb(ch)p Fq(.)664955 y Fl(val)d Fk(recv:)106 b Ff(\013)21 b Fk(chan)iFd(!)j Ff(\013)784 1128 y Fn(recv)49 b Fb(ch)74 b Fq(recei)n(v)o(es)27b(a)e(message)i(from)f(the)f(channel)j Fb(ch)o Fq(.)34b(This)26 b(operation)i(blocks)f(the)784 1241 y(calling)i(thread)f(until)f(there)h(is)f(another)h(thread)g(attempting)h(a)eFn(send)e Fq(operation)k(on)e(the)784 1354 y(channel)fFb(ch)o Fq(.)664 1528 y Fl(val)c Fk(sendEvt:)105 b Fc(\()pFf(\013)21 b Fk(chan)d(*)i Ff(\013)p Fc(\))26 b Fd(!)fFk(unit)f(event)664 1641 y Fl(val)e Fk(recvEvt:)105 bFf(\013)21 b Fk(chan)i Fd(!)i Ff(\013)c Fk(event)7841815 y Fq(These)h(functions)i(create)e(e)n(v)o(ent)g(v)n(alues)h(to)e(represent)j(the)e Fn(send)e Fq(and)i Fn(recv)e Fq(operations.)6641988 y Fl(val)i Fk(sendPoll:)105 b Fc(\()p Ff(\013)21b Fk(chan)d(*)i Ff(\013)p Fc(\))26 b Fd(!)f Fk(bool)7842162 y Fn(send)49 b(\()p Fb(ch)p Fn(,)g Fb(a)p Fn(\))76b Fq(attempts)28 b(to)f(send)h(the)g(message)g Fb(a)eFq(on)h(the)g(synchronous)k(channel)784 2275 y Fb(ch)pFq(.)d(If)23 b(this)i(operation)h(can)e(complete)h(without)g(blocking)h(the)d(calling)j(thread,)f(then)f(the)784 2388 y(message)34b(is)f(sent)g(and)g Fn(true)e Fq(is)i(returned.)58 b(Otherwise,)36b(no)d(communication)i(is)e(pre-)784 2501 y(formed)c(and)fFn(false)e Fq(is)h(returned.)44 b(This)27 b(function)j(is)e(not)g(recommended)i(for)d(general)784 2614 y(use;)d(it)g(is)f(pro)o(vided)j(as)d(an)h(ef)n(\002cienc)o(y)g(aid)g(for)g(certain)h(kinds)f(of)g(protocols.)664 2787 y Fl(val)e Fk(recvPoll:)105 b Ff(\013)20b Fk(chan)k Fd(!)h Ff(\013)c Fk(option)784 2961 y Fn(recvPoll)48b Fb(ch)80 b Fq(attempts)32 b(to)f(recei)n(v)o(e)h(a)e(message)i(from)f(the)g(channel)h Fb(ch)p Fq(.)50 b(If)30 b(there)7843074 y(is)h(no)f(other)i(thread)g(of)n(fering)g(to)fFn(send)e Fq(a)h(message)i(on)e Fb(ch)p Fq(,)h(then)h(this)f(returns)hFn(NONE)p Fq(,)784 3187 y(otherwise)i(it)d(returns)jFn(SOME)c Fq(wrapped)j(around)h(the)e(message.)55 b(This)32b(function)i(is)e(not)784 3300 y(recommended)38 b(for)d(general)i(use;)42 b(it)35 b(is)g(pro)o(vided)j(as)d(an)g(ef)n(\002cienc)o(y)i(aid)e(for)h(certain)784 3413 y(kinds)25 b(of)e(protocols.)6643586 y Fl(val)f Fk(wrap:)106 b Fc(\()p Ff(\013)21 b Fk(event)d(*)pFc(\()p Ff(\013)26 b Fd(!)f Ff(\014)5 b Fc(\)\))26 bFd(!)f Ff(\014)h Fk(event)784 3760 y Fn(wrap)49 b(\()pFb(ev)6 b Fn(,)50 b Fb(f)5 b Fn(\))85 b Fq(wraps)37 b(the)g(post-synchronizatio)q(n)42 b(action)37 b Fb(f)k Fq(around)d(the)f(e)n(v)o(ent)784 3873 y(v)n(alue)25 b Fb(ev)6 b Fq(.)6644047 y Fl(val)22 b Fk(wrapHandler:)103 b Fc(\()p Ff(\013)21b Fk(event)d(*)p Fc(\()p Fk(exn)24 b Fd(!)h Ff(\013)cFk(event)n Fc(\)\))k Fd(!)h Ff(\013)20 b Fk(event)7844220 y Fn(wrapHandler)48 b(\()p Fb(ev)6 b Fn(,)50 b Fb(f)5b Fn(\))73 b Fq(wraps)24 b(the)g(e)o(xception)j(handler)f(function)gFb(f)i Fq(around)e(the)784 4333 y(e)n(v)o(ent)21 b(v)n(alue)hFb(ev)7 b Fq(.)27 b(If,)20 b(during)j(e)o(x)o(ecution)g(of)d(some)h(post-synchronizat)q(ion)27 b(action)22 b(in)f Fb(ev)6b Fq(,)784 4446 y(an)30 b(e)o(xception)i(is)d(raised,)j(it)d(will)h(be)f(caught)i(and)f(passed)h(to)f Fb(f)5 b Fq(.)46 b(Nesting)30b(of)g(handlers)784 4559 y(w)o(orks)g(as)g(w)o(ould)g(be)g(e)o(xpected:)43 b(the)30 b(innermost)i(handler)g(is)d(the)h(one)g(in)l(v)n(ok)o(ed.)50 b(Note)784 4672 y(that)37 b(e)o(xceptions)j(raised)e(in)f(the)g(pre-synchronization)43 b(actions)38 b(in)f Fb(ev)42b Fq(\(i.e.,)d(actions)784 4785 y(de\002ned)25 b(by)eFn(guard)f Fq(and)i Fn(withNack)p Fq(\))d(are)j(not)g(handled)i(by)dFb(f)5 b Fq(.)664 4959 y Fl(val)22 b Fk(guard:)106 bFc(\()p Fk(unit)24 b Fd(!)h Ff(\013)c Fk(event)m Fc(\))26b Fd(!)f Ff(\013)c Fk(event)2136 5187 y Fq(6)p eop%%Page: 7 77 6 bop 361 555 a Fn(guard)49 b Fb(f)74 b Fq(creates)22b Fe(delayed)j Fq(e)n(v)o(ent)c(v)n(alue)h(from)e(the)h(function)iFb(f)5 b Fq(.)27 b(When)21 b(the)f(resulting)361 668y(e)n(v)o(ent)25 b(v)n(alue)g(is)f(synchronized)k(on,)d(the)g(function)h Fb(f)j Fq(will)24 b(be)g(e)n(v)n(aluated)j(and)e(the)f(result-)361781 y(ing)k(e)n(v)o(ent)g(v)n(alue)h(will)e(be)h(used)g(in)g(its)g(place)g(in)g(the)g(synchronization.)46 b(This)28 b(pro)o(vides)361894 y(a)e(mechanism)h(for)g(implementing)h(pre-synchronizati)q(on)k

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -