November 2018
Beginner to intermediate
260 pages
6h 12m
English
Semaphore is another way of synchronizing threads for solving the producer-consumer problem or guarding a critical section. Ignite's distributed semaphore data structure is IgniteSemaphore.
We can define a semaphore using the following syntax:
IgniteSemaphore semaphore = ignite.semaphore( "mySemaphore", // semaphore name. 20, // permits. true, // Release acquired permits if node, that owned them, left topology. true // Create if it doesn't exist.);
IgniteSemaphore has two important methods:
and other variants, such as acquire(int permits), tryAcquire(int permits), and acquireUninterruptibly(). Acquires a permit, or a given number of permits for acquire(int permits) and tryAcquire(int permits),
from this semaphore,
Read now
Unlock full access