Commit graph

22 commits

Author SHA1 Message Date
Daniel Larimer
e5ca765f15 clean up logging 2016-02-15 11:59:28 -05:00
dnotestein
27ac054883 Log thread creation and destruction 2014-11-03 16:59:19 -05:00
Eric Frias
307252e23a Call fc:🧵:quit() on thread destruction, and remove code that explicitly terminates threads from the destructors of the objects that own those threads.
Fix fc::thread to set the thread name in the Debugger when the name is set after thread construction.
When terminating a thread, cancel any tasks that have been schedule()d or async()ed but have not yet started executing.
When canceling a task blocked on a fc::mutex, notify the thread to reschedule the task to allow it to clean up the mutex's block list.
Fix a bug in managing the recursive lock count when tasks block on a fc::mutex
Reorder the code that manages the hard links for log files to avoid an exception generated by unlinking a locked file on Windows.
2014-10-21 10:25:28 -04:00
Eric Frias
b34a222dc5 Remove #ifdefed-out code 2014-10-16 17:50:58 -04:00
Eric Frias
e5666cca54 Convert ready_head (list of fibers able to run immediately) into a priority heap 2014-10-16 16:26:19 -04:00
Eric Frias
1af4ac6a5c Schedule fibers in the order they are asynced or unblocked. Earlier behavior was always to start newly-asycned tasks before resuming existing tasks, so existing tasks could be starved if there was a steady stream of new tasks created. Now all tasks are started or resumed in the order they are created or unblocked. 2014-10-16 15:25:31 -04:00
Eric Frias
130da3623e Allow fibers to be canceled while they're sleeping or blocked on promises 2014-09-08 10:41:59 -04:00
Eric Frias
3222dc7c0b When reusing a context, re-initialize most of its fields. This fixes at least two errors:
- we were canceling tasks that hadn't been canceled, because the canceled flag was left set to true and the next task assigned to the context then became canceled as soon as it yielded
 - we were resumeing blocked tasks before they should have resumed, because their blocking_promises list wasn't cleared and they were unblocking because the erroneous promises were fulfilled
As a debugging aid, we also record the cancellation reason whenever a task is canceled, and include that in the canceled_exception (this is only enabled in debug builds)
2014-08-28 15:43:26 -04:00
Eric Frias
8841f5e271 Import thread/task_specific variables 2014-08-27 12:20:19 -04:00
Eric Frias
27096f15a7 Log the names of tasks to the log file (now contains thread_name:task_name} 2014-08-24 18:33:05 -04:00
Nathan Hourt
9e75d47ba3 Fix to an issue causing a thread to exit if any fiber therein self-cancels 2014-08-21 14:36:29 -04:00
Eric Frias
d847f6469a Allow us to require assigning descriptions to all async tasks to aid in debugging 2014-07-27 17:37:21 -04:00
dnotestein
9e320a3db8 Add descriptions for a bunch of async tasks, remove logging during thread::quit to avoid crashes for now until we cleanup thread quit code 2014-07-27 00:09:15 -04:00
Daniel Larimer
eed62c8338 sockets now wait for any pending write or read operations to finish before destructing 2014-07-17 17:03:25 -04:00
Vikram Rajkumar
e9b1b8ec2e Use a separate thread for log compression 2014-07-03 17:24:06 -04:00
Daniel Larimer
892df5c0b7 canceled scheduled tasks return immediately when waited upon 2014-06-28 21:46:10 -04:00
Eric Frias
061007ee29 In debug builds, set the thread name in the debugger to match the name given to fc::thread ctor 2014-04-01 16:56:11 -04:00
Eric Frias
fdbaf88e5e Provide a way to intercept Win32 structured exceptions in async tasks
Something about the stacks created by boost::context prevents global structured exception handlers
from being called.  This allows the user to register a handler which will be called when there
is an unhandled structured exception in async task.
2014-03-08 18:48:19 -05:00
dnotestein
35077ea231 Set minimum sleep time to 10ms to avoid potential race where the thread wakes back up immediately after being put on sleep queue. This can probably be reduced to about 2ms, but this just seemed safer for now (DanL suggested 10ms). 2013-12-06 00:22:06 -05:00
Daniel Larimer
7bf6374299 MAJOR BUG FIX - fc::usleep causing hang&leak
In certain cases when usleep is passed a small value, there is
a race condition that would cause the process to hang and then
when an attempt to quit the thread was made new contexts would
be allocated rapidly filling all available memory.
2013-08-19 14:44:13 -04:00
Daniel Larimer
b07aed4a22 Update use of fc::string and fc::vector. 2013-06-27 14:19:08 -04:00
Daniel Larimer
59a121d64b Updating FC with changes from phoenix-int 2013-06-05 15:19:00 -04:00
Renamed from src/thread.cpp (Browse further)