-
Notifications
You must be signed in to change notification settings - Fork 3
/
Queue.java
62 lines (54 loc) · 1.87 KB
/
Queue.java
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
60
61
62
package inspire.validator;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.HashMap;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
public class Queue {
public RequestConfig config;
public CloseableHttpClient client;
private AtomicInteger size = new AtomicInteger();
public synchronized boolean incIfSmaller(int limit) {
if (size.get() < limit) {
size.incrementAndGet();
return true;
}
else
return false;
}
public void decrement() {
size.decrementAndGet();
}
private static HashMap<Integer, Queue> queues = new HashMap<Integer, Queue>();
public static Queue get(int nr) {
return queues.get(nr);
}
public static Queue init(int nr) {
Queue queue = new Queue();
queues.put(nr, queue);
return queue;
}
}
/*
* Copyright 2020 EUROPEAN UNION
* Licensed under the EUPL, Version 1.2 or - as soon as they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence").
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://ec.europa.eu/isa2/solutions/european-union-public-licence-eupl_en
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* Date: 2020/06/08
* Authors:
* European Commission, Joint Research Centre - [email protected]
*
* This work was supported by the Interoperability solutions for public
* administrations, businesses and citizens programme (http://ec.europa.eu/isa2)
* through Action 2016.10:
* European Location Interoperability Solutions for e-Government (ELISE)
*/