Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the files generated by javasphinx in the git
[simgrid.git] / docs / source / java / org / simgrid / msg / Semaphore.rst
1 class org.simgrid.msg.Semaphore
2 ===============================
3
4 .. java:package:: org.simgrid.msg
5    :noindex:
6
7 .. java:type:: public class Semaphore
8
9    A semaphore implemented on top of SimGrid synchronization mechanisms. You can use it exactly the same way that you use classical semaphores but to handle the interactions between the processes within the simulation.
10
11 Fields
12 ------
13 capacity
14 ^^^^^^^^
15
16 .. java:field:: protected final int capacity
17    :outertype: Semaphore
18
19    Semaphore capacity, defined when the semaphore is created. At most capacity process can acquire this semaphore at the same time.
20
21 Constructors
22 ------------
23 Semaphore
24 ^^^^^^^^^
25
26 .. java:constructor:: public Semaphore(int capacity)
27    :outertype: Semaphore
28
29    Creates a new semaphore with the given capacity. At most capacity process can acquire this semaphore at the same time.
30
31 Methods
32 -------
33 acquire
34 ^^^^^^^
35
36 .. java:method:: public native void acquire(double timeout) throws TimeoutException
37    :outertype: Semaphore
38
39    Locks on the semaphore object until the provided timeout expires
40
41    :param timeout: the duration of the lock
42    :throws TimeoutException: if the timeout expired before the semaphore could be acquired.
43
44 acquire
45 ^^^^^^^
46
47 .. java:method:: public void acquire()
48    :outertype: Semaphore
49
50    Locks on the semaphore object with no timeout
51
52 finalize
53 ^^^^^^^^
54
55 .. java:method:: @Deprecated @Override protected void finalize() throws Throwable
56    :outertype: Semaphore
57
58    Deletes this semaphore when the GC reclaims it
59
60 getCapacity
61 ^^^^^^^^^^^
62
63 .. java:method:: public int getCapacity()
64    :outertype: Semaphore
65
66    Returns the semaphore capacity
67
68 nativeInit
69 ^^^^^^^^^^
70
71 .. java:method:: public static native void nativeInit()
72    :outertype: Semaphore
73
74    Class initializer, to initialize various JNI stuff
75
76 release
77 ^^^^^^^
78
79 .. java:method:: public native void release()
80    :outertype: Semaphore
81
82    Releases the semaphore object
83
84 wouldBlock
85 ^^^^^^^^^^
86
87 .. java:method:: public native boolean wouldBlock()
88    :outertype: Semaphore
89
90    returns a boolean indicating it this semaphore would block at this very specific time Note that the returned value may be wrong right after the function call, when you try to use it... But that's a classical semaphore issue, and SimGrid's semaphores are not different to usual ones here.
91