类 Schedule
java.lang.Object
io.github.vipcxj.schedule.Schedule
- 所有已实现的接口:
Closeable,AutoCloseable
High-performance schedule manager
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明schedule the callbackschedule the callbackvoidclose()static EventHandleUsed for CAS.static Scheduleinstance()Get the singleton instance.
-
构造器详细资料
-
Schedule
public Schedule()
-
-
方法详细资料
-
instance
Get the singleton instance.- 返回:
- singleton instance
-
close
public void close()- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Closeable
-
createInvalidHandle
Used for CAS. For example:static class DisposableImpl implements JDisposable { // Create a handle placeholder representing invalid handle. private static final EventHandle INVALID = Schedule.createInvalidHandle(); private volatile EventHandle handle; private static final AtomicReferenceFieldUpdater<DisposableImpl, EventHandle> HANDLE = AtomicReferenceFieldUpdater.newUpdater(DisposableImpl.class, EventHandle.class, "handle"); void updateHandle(EventHandle newHandle) { while (true) { EventHandle handle = this.handle; if (handle == INVALID || HANDLE.weakCompareAndSet(this, handle, newHandle)) { return; } } } public void dispose() { while (true) { EventHandle handle = this.handle; if (handle == INVALID) { return; } if (HANDLE.weakCompareAndSet(this, handle, INVALID)) { handle.remove(); return; } } } public boolean isDisposed() { return handle == INVALID; } }- 返回:
- a invalid handle.
-
addEvent
schedule the callback- 参数:
time- the time when the callback invoked.unit- the time unit.callback- the callback.
-
addEvent
schedule the callback- 参数:
nanoTime- the time in nanoseconds when the callback invoked.callback- the callback.
-