Commit Graph

20 Commits

Author SHA1 Message Date
CraftBukkit/Spigot
e719bbd88c 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..

By: Wesley Wolfe <weswolf@aol.com>
2012-08-26 10:25:11 -05:00
CraftBukkit/Spigot
b1d40801aa 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.

By: Wesley Wolfe <weswolf@aol.com>
2012-08-14 06:09:51 -05:00
CraftBukkit/Spigot
fa547512af Deprecation cleanup.
By: Erik Broes <erikbroes@grum.nl>
2012-01-30 21:51:53 +01:00
CraftBukkit/Spigot
af11cea8fe Revert "Do not immediately re-queue repeating tasks, or they may simply keep repeating on this tick, until the 35ms time limit runs out." See 3632d99122 (commitcomment-478252)
This reverts commit 3632d99122e8795cadb8f94e14e42eb4aa6d7c4c.

By: Dinnerbone <dinnerbone@dinnerbone.com>
2011-07-14 23:21:28 +01:00
CraftBukkit/Spigot
e2f2ed1c17 Do not immediately re-queue repeating tasks, or they may simply keep repeating on this tick, until the 35ms time limit runs out.
By: Afforess <afforess@gmail.com>
2011-07-13 17:26:33 -07:00
CraftBukkit/Spigot
f7df7a7870 Possible fix for cancelled CraftScheduler tasks still running.
By: EvilSeph <evilseph@unaligned.org>
2011-06-30 02:18:11 -04:00
CraftBukkit/Spigot
9bf573516b Generic cleanup of the org.bukkit.craftbukkit classes.
By: Erik Broes <erikbroes@grum.nl>
2011-06-12 01:12:43 +02:00
CraftBukkit/Spigot
776b9efd3e Whitespace + general cleanup
By: Erik Broes <erikbroes@grum.nl>
2011-05-14 16:29:42 +02:00
CraftBukkit/Spigot
7bbe446bd6 Improved the Scheduler.
Adds nag message when async tasks are not properly shut down and adds a limiter for sync tasks. Once they use 35ms in a single tick, any remaining tasks are not executed until later ticks. Adds a method to report the pending tasks and one to report active worker threads

By: Raphfrk <raphfrk@gmail.com>
2011-04-28 20:10:39 +01:00
CraftBukkit/Spigot
070c214267 Update for 1.4_00_01 -- if you bypassed Bukkit, you will most likely break.
By: Erik Broes <erikbroes@grum.nl>
2011-04-20 19:05:14 +02:00
CraftBukkit/Spigot
91e69e54b4 Don't want the scheduler taking invalid arguments as well.
By: sk89q <the.sk89q@gmail.com>
2011-04-18 23:52:19 -07:00
CraftBukkit/Spigot
c4d411e2bf Fixed CraftScheduler to catch exceptions thrown by tasks, rather than crash the server.
By: sk89q <the.sk89q@gmail.com>
2011-04-18 23:47:49 -07:00
CraftBukkit/Spigot
a7ed1c966b Code cleanup, fixed doors, chunk entity fetching
By: Tahg <tahgtahv@gmail.com>
2011-03-11 16:25:35 -05:00
CraftBukkit/Spigot
ed40bc0373 returning if a thread is not alive should happen before any changes to
the list of workers, hence the return statement should be in the
synchronized block.

By: Andrew Ardill <andrew.ardill@gmail.com>
2011-02-21 12:30:45 +11:00
CraftBukkit/Spigot
70098c0548 implementation of isQueued()
By: Andrew Ardill <andrew.ardill@gmail.com>
2011-02-21 12:28:35 +11:00
CraftBukkit/Spigot
e44ffec0f5 implementation of isCurrentlyRunning(int taskId);
Burrows down to the worker thread assigned to this task, and returns
its alive status. If no such thread exists, then the task is not
running!

By: Andrew Ardill <andrew.ardill@gmail.com>
2011-02-14 15:29:52 +11:00
CraftBukkit/Spigot
886838b453 Allows calling of functions in the main thread
By: Raphfrk <raphfrk@gmail.com>
2011-02-12 00:29:23 +00:00
CraftBukkit/Spigot
85e1d48e88 Fixes a deadlock issue in CraftScheduler
By: Raphfrk <raphfrk@gmail.com>
2011-02-13 03:45:34 +00:00
CraftBukkit/Spigot
6a5734b2ff @Override interface implementation is 1.6 exclusively
By: Erik Broes <erikbroes@grum.nl>
2011-02-07 11:03:56 +01:00
CraftBukkit/Spigot
622ca3e68c Scheduler
By: Raphfrk <raphfrk@gmail.com>
2011-02-02 23:53:04 +00:00