-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIDecRefQueue.java
More file actions
48 lines (39 loc) · 880 Bytes
/
IDecRefQueue.java
File metadata and controls
48 lines (39 loc) · 880 Bytes
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
/**
* This file was automatically generated from IDecRefQueue.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.microsoft.z3;
import java.util.LinkedList;
abstract class IDecRefQueue
{
protected Object m_lock = new Object();
protected LinkedList<Long> m_queue = new LinkedList<Long>();
protected final int m_move_limit = 1024;
protected abstract void incRef(Context ctx, long obj);
protected abstract void decRef(Context ctx, long obj);
protected void incAndClear(Context ctx, long o)
{
incRef(ctx, o);
if (m_queue.size() >= m_move_limit)
clear(ctx);
}
protected void add(long o)
{
if (o == 0)
return;
synchronized (m_lock)
{
m_queue.add(o);
}
}
protected void clear(Context ctx)
{
synchronized (m_lock)
{
for (Long o : m_queue)
decRef(ctx, o);
m_queue.clear();
}
}
}