Repository navigation
Refactor/use worker threads in timer dispatch - #10
Merged
Merged
Conversation
Timer engine now spawns worker threads to run the actual tasks. Sockets are now strictly locked with sock->lock, since this simplifies the interplay between timers, input handler and the user socket handler.
Oops, this caused doublelocking (timer_free) and timers were never released.
Not sure if this helps that much, but if clearly a thread only needs to read data from the socket, it can use `rdlock` then.
Lvl-ip spends its most time here, and felt like the 1ms resolution is a bit too fine for the purposes.
We really want to lock it and not bail out. Also, added error printing if the lock can't be acquired.
This still isn't how I'd like it to be, but the twist is that we need to lock the timer, remove it from the list, and only then can we unlock it. Which begs the question, if refcnt is 0, nobody should be able to acquire the timer reference anymore!
I know, sleeping like this is not that maintainable. Proper solution would be to poll the HTTP server for when it's up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces stability improvements and removes coding errors related to multithreading:
usleep(1000)most of the time was spent just iterating over the timers.Most of the mutexes are now unused, and should be removed in the near future. Maybe in this changeset even.