📄 cond.3
字号:
.\" Copyright (c) 1999-2000 Orn E. Hansen <oe.hansen@gamma.telenordia.se>.\".\" Permission is granted to make and distribute verbatim copies of this.\" manual provided the copyright notice and this permission notice are.\" preserved on all copies..\".\" Permission is granted to copy and distribute modified versions of this.\" manual under the conditions for verbatim copying, provided that the.\" entire resulting derived work is distributed under the terms of a.\" permission notice identical to this one.\" .TH THREADS 3 "10 Feb 2000" "Threads 2.0" "Threads C++ Library".SH NAMEcond \- A class, for process synchronisation..SH SYNOPSIS.B #include <thread.h>.sp 2.B ....sp 0.B cond variable(attributes::process_private);.sp 0.B ....SH DESCRIPTIONThe.I condclass is a part of the threads C++ library that focuses onsimplifying program threading.The cond class, provides means to pass conditions over to a differentthread or process. It can be initialized as working only within theprocess of its creation, and associated threads. Or to share itsresources with other processes that so desire. This can be accomplishedby specifying either.I attributes::process_sharedas the initializing parameter, to create a shared condition variable,or.I attributes::process_privateas shown in the synopsis above, to create a variable that is onlyviewable within the current process tree..LPThese methods are listed here, with some explanation on how theyfunction..TP 12.B wait(mutex&)The mutex passed, is assumed locked on entry and owned by thecalling process. The method then unlocks the mutex, and entersa state of suspension, until a signal is received through the.I signal()method, when it will relock the mutex and return to the callingprocess..TP 12.B timedwait(mutex&, struct timespec *)Again, as in above, the mutex is assumed locked and owned by thecalling process ( it is upon the user to make sure that this isthe case ). The process immediately unlocks the mutex, and entersa state of slumber until a signal is recieved, as in the caseof.I wait(mutex&)However, the difference here is that the method will only wait untila specified timetick has been reached. If this timetick isreached before the condition variable is able to achieve asignal, it will return with a ETIMEDOUT, or a EINTR if it receiveda cancel signal while inside the wait loop. If a signal occurs,the returned value will be 0..TP 12.B timedwait_rel(mutex&, struct timespec *)This method is very similar to the above, it only differs from theabove method in that the.I struct timespec *actually points to a specification of a relative time. Giving theperiod, that the method is supposed to wait, instead of theactual moment. In all other respects, including the returnedvalues, it is equivalent to the above..TP 12.B signal()All processes that are waiting on a given condition variable, areput into a buffer, and when this method is called, the processthat first enter the wait state on the variable will be awakened,in a FIFO manner..TP 12.B broadcast()This method will awaken all processes, that are waiting on thegiven condition variable. Effectively emptying the buffer..LPIn a shared environment, it may be desired that condition variableresources be addressed differently from other resources belongingto a process..TP 12.B project_part(const char *)Give all resources that are of type condition variables, a namethat identifies them seperately, yet still branched from themain process. The passed arguement is a branch name, that willidentify all created condition variables. This is a staticmethod, that will apply to all condition variables created afterthe call..LPSuggestions and questions about the threads library should bedirected to:.IPkdb-list@brevet.nu.LPOr, to the author specified below. The threads home page is located at:.IPhttp://user.tninet.se/~dpn659b/threads.html.LP.SH AUTHORVersion 2.0Copyright (C) 1999-2000 Orn E. Hansen <oe.hansen@gamma.telenordia.se>..LPThanks to those who reported their suggestions on how toimprove the threads library.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -