forked from kohsuke/com4j
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathComThread.java
More file actions
64 lines (57 loc) · 2.15 KB
/
ComThread.java
File metadata and controls
64 lines (57 loc) · 2.15 KB
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
63
64
package com4j;
import java.lang.ref.ReferenceQueue;
/**
* Interface for threads managed by com4j.
*
* <p>
* COM objects constructed via Com4j use {@link ComThreadMulti}, and
* those objects can be accessed from all Java threads.
*
* COM objects constructed outside of Com4j and wrapped that can only be
* accessed from the thread that created the object and use
* {@link ComThreadSingle}.
*
* <p>
* This is because COM objects are inherently tied to the thread that created it,
* and therefore all the invocations must be routed through the creator thread.
* See http://msdn.microsoft.com/en-us/library/ms809971.aspx for more discussions.
*/
public interface ComThread {
/**
* Executes a {@link Task} in a {@link ComThread}
* and returns its result.
* @param task The task to be executed
* @param <T> The type of the return value.
* @return The result of the Task
*/
public <T> T execute(Task<T> task);
/**
* Checks if the current thread this instance of ComThread;
*/
boolean isCurrentThread();
/**
* Keeps track of wrappers that should be IUnknown::release-d.
*/
public ReferenceQueue<Wrapper> getCollectableObjects();
/**
* Adds a {@link Com4jObject} to the live objects of this {@link ComThread}
* <p>
* This method increases the live object count of this thread and fires an
* {@link ComObjectListener#onNewObject(Com4jObject)} event to all listeners.
* </p>
* @param r The new {@link Com4jObject}
*/
public void addLiveObject( Com4jObject r );
/**
* Adds a {@link ComObjectListener} to this {@link ComThread}
* @param listener the new listener
* @throws IllegalArgumentException if the <code>listener</code> is <code>null</code> or if the listener is already registered.
*/
public void addListener(ComObjectListener listener);
/**
* Removes the {@link ComObjectListener} from this {@link ComThread}
* @param listener The listener to remove
* @throws IllegalArgumentException if the listener was not registered to this {@link ComThread}
*/
public void removeListener(ComObjectListener listener);
}