Comments (5)
why should it be saying not-valid?
Boost.Fibers
adopts a non-intrusive design where fibers scheduler is initialized when the fibers code is first called.
boost::this_fiber::get_id()
calls internally boost::fibers::context::active()
which does such one-time initialization when it is called in a new thread. the main thread is not different in this sense.
In short, you can use fibers from your main function and your main function becomes one of the fibers just because the scheduler must return to it when other fibers yield or are blocked on something.
if you read my post about fibers https://www.romange.com/2018/12/15/introduction-to-fibers-in-c-/
you could test it by copying the example below from the blog into your main function. fb1.join();
is a blocking condition for a main fiber where fiber scheduler switches the control to other fibers and then eventually switches back. The same true with fb2
.
int keep_going = true;
int iteration = 1;
fibers::mutex mu;
fibers::conditional_variable cv;
auto cb = [&] {
while (keep_going) {
do_something_fiber_blocking();
++iteration;
cv.notify_on();
}
};
fiber fb1(cb);
fiber fb2([&] {
{
std::unique_lock<fibers::mutex> lock(mu);
cv.wait(lock, [&] { return iteration > 5;});
}
keep_going = false;
});
fb1.join();
fb2.join();
from gaia.
from gaia.
I think i understand your point now. fibers are initialized the first time you utilize them. So if you don't utilize the fiber functionality then that code is not running fibers. Got it. I think then i know what to do.
Thanks a lot for the help.
from gaia.
from gaia.
I did not have any problem with fibers in that sense. I can see my functions inside fibers when doing profiling with gperftools @akseg73
from gaia.
Related Issues (13)
- More helpful docs. HOT 1
- add documentation on how to build dockerized binaries HOT 2
- participate Hacktoberfest and add more issues labeled Hacktoberfest/good first issue
- gaia and microservices on k8s HOT 2
- introduce gaia custom error messages HOT 1
- GAIA fails sometimes to write a file to GCS HOT 1
- asio::ssl introduces 2 redundant copies HOT 1
- Work stealing mappers HOT 1
- implement mrprint instead of pprint with sptaskpool
- merge MapperExecutor::GetStats and metric_map_ logic HOT 1
- partial pipeline run
- logs should include a fiber id HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gaia.