mirror of
https://github.com/Team4388/Robot-Essentials.git
synced 2026-06-09 00:38:01 -06:00
port from 2023
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package frc4388.utility;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DeferredBlock {
|
||||
private static ArrayList<Runnable> m_blocks = new ArrayList<>();
|
||||
private static boolean m_hasRun = false;
|
||||
|
||||
public DeferredBlock(Runnable block) {
|
||||
m_blocks.add(block);
|
||||
}
|
||||
|
||||
public static void execute() {
|
||||
if (m_hasRun) return;
|
||||
|
||||
for (Runnable block : m_blocks) {
|
||||
block.run();
|
||||
}
|
||||
|
||||
m_blocks.clear(); // for garbage collection
|
||||
m_hasRun = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user