Commit Graph

27 Commits

Author SHA1 Message Date
CraftBukkit/Spigot
2c6b6e11dd Remove erroneous break statement in scheduler. Fixes BUKKIT-3395
By: Wesley Wolfe <weswolf@aol.com>
2013-01-27 23:00:14 -06:00
CraftBukkit/Spigot
eeded7f6fd Remove runner leak on async tasks. Fixes BUKKIT-3288
In some situations, an async task could be cancelled with no tasks
pending. This means the finally {} block from run() never gets executed
properly on the last async task to have run, as it expected to be
executed again.

This fix takes the only spot that the task period is set to cancelled
and will check to see if the task should be purged from the runners
list.

By: Wesley Wolfe <weswolf@aol.com>
2012-12-23 05:13:33 -06:00
CraftBukkit/Spigot
77e811ab06 Fixed some async tasks running synchronously. Fixes BUKKIT-2934
Additionally refactored cancel method to be more object-oriented.

By: Wesley Wolfe <weswolf@aol.com>
2012-11-14 16:47:21 -06:00
CraftBukkit/Spigot
dd1816bda4 Implement new scheduler API. Adds BUKKIT-836
The implementation for the new methods mimics the old methods. The final
call for the old methods now maps to the new methods with an additional
call to get id.

By: Wesley Wolfe <weswolf@aol.com>
2012-10-06 16:23:56 -05:00
CraftBukkit/Spigot
0d3ff61b07 Fix typo causing a task to be repeated in debug. Addresses BUKKIT-2549
An internal method for making the debug output for CraftScheduler's
async tasks was erroneously using the 'this' reference when the loop
should be referencing the current task.

By: Wesley Wolfe <weswolf@aol.com>
2012-09-28 02:39:22 -05:00
CraftBukkit/Spigot
2a57bac117 Bulk pending cleanup.
By: Wesley Wolfe <weswolf@aol.com>
2012-09-09 23:19:28 -05:00
CraftBukkit/Spigot
c650c443b3 Add information about async tasks to CrashReports. Addresses BUKKIT-2491
Async tasks are notorious for causing CMEs and corrupted data when
accessing the API. This change makes a linked list to track recent tasks
that may no longer be running. It is accessed via the toString method on
the scheduler. This behavior is not guaranteed, but it is accessible as
such currently.

Although toString is located in the scheduler, its contract does not
guarantee an accurate or up to date call when accessed from a second
thread.

By: Wesley Wolfe <weswolf@aol.com>
2012-09-09 00:34:41 -05:00
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