File: threadwait.mdc

package info (click to toggle)
freemat 4.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 141,800 kB
  • ctags: 14,082
  • sloc: ansic: 126,788; cpp: 62,046; python: 2,080; perl: 1,255; sh: 1,146; yacc: 1,019; lex: 239; makefile: 100
file content (59 lines) | stat: -rw-r--r-- 1,634 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

 Usage

The threadwait function waits for the given thread to
complete execution, and stops execution of the current
thread (the one calling threadwait) until the given thread
completes. The syntax for its use is

     success = threadwait(handle)

where handle is the value returned by threadnew and success
is a logical vaariable that will be 1 if the wait was
successful or 0 if the wait times out. By default, the wait
is indefinite. It is better to use the following form of the
function

     success = threadwait(handle,timeout)

where timeout is the amount of time (in milliseconds) for
the threadwait function to wait before a timeout occurs. If
the threadwait function succeeds, then the return value is a
logical 1, and if it fails, the return value is a logical 0.
Note that you can call threadwait multiple times on a
thread, and if the thread is completed, each one will
succeed.


 Example

Here we lauch the sleep function in a thread with a time
delay of 10 seconds. This means that the thread function
will not complete until 10 seconds have elapsed. When we
call threadwait on this thread with a short timeout, it
fails, but not when the timeout is long enough to capture
the end of the function call.

  --> a = threadnew;
  --> threadstart(a,'sleep',0,10);  % start a thread that
  will sleep for 10
  --> threadwait(a,2000)            % 2 second wait is not
  long enough

  ans =
   0

  --> threadwait(a,10000)           % 10 second wait is long
  enough

  ans =
   1

  --> threadfree(a)


* FreeMat_Documentation
* FreeMat_Threads
* Generated on Thu Jul 25 2013 17:18:29 for FreeMat by
  doxygen_ 1.8.1.1