简体   繁体   中英

any can please explain me this boost create_thread line?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM