Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost fiber #173

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft

Boost fiber #173

wants to merge 27 commits into from

Conversation

pmconrad
Copy link

@pmconrad pmconrad commented Oct 10, 2019

Proof-of-concept for switching fc::thread to boost::fibers . Replaces fc::do_parallel with boost::fibers constructs. Related tests are working.
Still much to do.
Requires Boost-1.62+.
boost::fibers contains a memory leak in algorithm_with_properties that still needs to be worked around.

@abitmore
Copy link
Member

Boost.Fiber depends upon Boost.Context. Boost version 1.61.0 or greater is required.

Ubuntu 16 users would need to build boost by themselves.

@pmconrad
Copy link
Author

Yes. I think by the time this gets into production Ubuntu-20.04 will be out. We can consider bumping requirements to Boost-1.62 and C++17 then.

@pmconrad
Copy link
Author

pmconrad commented Nov 15, 2019

Got rid of the memory leak. All tests working locally.

There are some key differences to the old fc::thread implementation:

  • A thread that wants to receive async task assignments from other threads must call fc::initialize_fibers() first.
  • A task that is being pushed into another thread will only be pushed when the current fiber yields.
  • A thread that still has fibers in its queue will not terminate, even if the "main" fiber exits. This is particularly nasty for background fibers started from the main thread - they will prevent the program from exiting, even if the main fiber has left main().
  • Unlike fc::task, there is no support for cancelling a fiber. A means to cancel a task that is scheduled in the background must be implemented separately. Due to this, fc::schedule should not be used with a time in the far future.
  • boost::fiber synchronization mechanisms (mutexes and condition variables) do not work in destructors of objects with static lifetime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants