Reputation:
im implementing a github commit on my repo but i see a line and i dont understeand what it means, here is the line:
threadGroup.create_thread(boost::bind(&BeeKeeper, boost::cref(chainparams)));
i understeand the threadGroup, i know what it its and what its for, i have a function called BeeKeeper() so i guess that is calling that function but i dont get the boost::cref, i dont have a class named chainparams i just have a file called chainparams.h is this just a tag to create the thread with that name or what its for?
Thanks.
Upvotes: 0
Views: 58
Reputation: 393674
std::bind. boost::bind etc. all bind arguments by value. To pass a referece, you need to wrap them with a std::reference_wrapper
.
std::ref
and std::cref
(or boost's equivalents) are functions that return those wrappers.
See If the stored argument arg is of type
So you have a variable named chainparams
that you pass, by reference, to the thread function.
Upvotes: 0