9 Commits

Author SHA1 Message Date
Senmori
9f49ad60e7 Remove magic values in scheduler package 2018-03-26 15:34:33 +11:00
blablubbabc
bde2a93cfe Add BukkitTask#isCancelled 2017-09-02 17:04:29 +10:00
Wesley Wolfe
092800af26 Fixed some async tasks running synchronously. Fixes BUKKIT-2934
Additionally refactored cancel method to be more object-oriented.
2012-11-14 16:47:21 -06:00
Wesley Wolfe
3307d489da Fix Future task waiting logic. Fixes BUKKIT-2408
Previously, the timeout would erroneously get converted to milliseconds
twice. The second conversion was removed.

Spurious wakeups were not handled properly, and would instead throw a
TimeoutException even if the waited time was not reached..
2012-08-26 10:25:11 -05:00
Wesley Wolfe
dcd01bf0c0 Rewrite scheduler. Fixes BUKKIT-1831, and BUKKIT-845
The new scheduler uses a non-blocking methodology. Combining volatile
references to make a linked reference chain, with the atomic reference
handling the tail, tasks are queued without waiting for locks. The main
thread will no longer limit the length of time spend for scheduled tasks,
but no task will run twice in the same tick. Scheduling a new task inside of
a synchronous task will always run the new task during the same tick,
assuming there is no supplied delay > 0.

Asynchronous tasks are now run using a thread pool. Any thread-local
implemenation should now account for threads being reused between
executions.

Race conditions were carefully examined and the order of logic is now very
important. Each task is placed in a secondary collection before removal from
primary collections. Thus, by reading tasks from the collections in the same
order they travel, it retains state-safety. This does make modifications
less responsive in some situations, as the task may be transitioning before
the modifier accesses it. This cost outweighs the requirement to synchronize
on the scheduler; previously any conflict would be first-come-first-serve,
with the main thread backing out arbitrarily.
2012-08-22 16:41:46 -05:00
Erik Broes
137880b727 Deprecation cleanup. 2012-02-18 13:06:12 -05:00
Erik Broes
9adc03abab Generic cleanup of the org.bukkit.craftbukkit classes. 2011-06-12 12:51:54 +02:00
Tahg
078f48c0fb Code cleanup, fixed doors, chunk entity fetching 2011-03-11 16:25:35 -05:00
Raphfrk
973d61c418 Allows calling of functions in the main thread 2011-02-13 22:12:26 -05:00