Package org.robwork.sdurw_common
Class ThreadPoolPtr
- java.lang.Object
-
- org.robwork.sdurw_common.ThreadPoolPtr
-
public class ThreadPoolPtr extends java.lang.ObjectPtr stores a pointer and optionally takes ownership of the value.
-
-
Constructor Summary
Constructors Constructor Description ThreadPoolPtr()Default constructor yielding a NULL-pointer.ThreadPoolPtr(long cPtr, boolean cMemoryOwn)ThreadPoolPtr(ThreadPool ptr)Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadPool__ref__()Dereferencing operator.voidaddWork(SWIGTYPE_p_boost__functionT_void_frw__common__ThreadPool_pF_t work)Add work to the thread pool.ThreadPoolCPtrcptr()voiddelete()ThreadPoolderef()The pointer stored in the object.booleanequals(ThreadPool p)static longgetCPtr(ThreadPoolPtr obj)ThreadPoolgetDeref()Member access operator.longgetNumberOfThreads()Get number of threads in the pool.longgetQueueSize()Get the number of current tasks in the queue (tasks are removed from queue when
done).booleanisNull()checks if the pointer is nullbooleanisShared()check if this Ptr has shared ownership or none
ownershipbooleanisStopping()Check if work tasks are supposed to shut itself down.
This function should be called from long-running worker functions to let them shut down
gracefully.
voidstop()Stop processing more work in the queue, and try to stop running work if possible.
Long-running work should check if the isStopping function returns true and shut down
gracefully.
Interrupts are issued, so if there is interruption points in the WorkFunction,
the work should check for boost::thread_interrupted exceptions and shut down gracefully.voidwaitForEmptyQueue()Wait until the task queue becomes empty.
-
-
-
Constructor Detail
-
ThreadPoolPtr
public ThreadPoolPtr(long cPtr, boolean cMemoryOwn)
-
ThreadPoolPtr
public ThreadPoolPtr()
Default constructor yielding a NULL-pointer.
-
ThreadPoolPtr
public ThreadPoolPtr(ThreadPool ptr)
Do not take ownership of ptr.
ptr can be null.
The constructor is implicit on purpose.
-
-
Method Detail
-
getCPtr
public static long getCPtr(ThreadPoolPtr obj)
-
delete
public void delete()
-
deref
public ThreadPool deref()
The pointer stored in the object.
-
__ref__
public ThreadPool __ref__()
Dereferencing operator.
-
getDeref
public ThreadPool getDeref()
Member access operator.
-
equals
public boolean equals(ThreadPool p)
-
isShared
public boolean isShared()
check if this Ptr has shared ownership or none
ownership- Returns:
- true if Ptr has shared ownership, false if it has no ownership.
-
isNull
public boolean isNull()
checks if the pointer is null- Returns:
- Returns true if the pointer is null
-
cptr
public ThreadPoolCPtr cptr()
-
getNumberOfThreads
public long getNumberOfThreads()
Get number of threads in the pool.
-
stop
public void stop()
Stop processing more work in the queue, and try to stop running work if possible.
Long-running work should check if the isStopping function returns true and shut down
gracefully.
Interrupts are issued, so if there is interruption points in the WorkFunction,
the work should check for boost::thread_interrupted exceptions and shut down gracefully.
-
isStopping
public boolean isStopping()
Check if work tasks are supposed to shut itself down.
This function should be called from long-running worker functions to let them shut down
gracefully.
- Returns:
- true if thread should shut down.
-
addWork
public void addWork(SWIGTYPE_p_boost__functionT_void_frw__common__ThreadPool_pF_t work)
Add work to the thread pool.
-
getQueueSize
public long getQueueSize()
Get the number of current tasks in the queue (tasks are removed from queue when
done).- Returns:
- the number of current tasks.
-
waitForEmptyQueue
public void waitForEmptyQueue()
Wait until the task queue becomes empty.
-
-