0

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.

1 Answers1

0

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.

sehe
  • 374,641
  • 47
  • 450
  • 633
  • based on your answere i search in the code and yes, i found a line that creates chainparams = Params(). But if i dont have a class with the variables in it and i only have them on a .h? what i can do then? –  Mar 15 '21 at 22:00
  • i find something on my code that called its like this: boost::thread(void(*Shutdown)(void*), NULL); –  Mar 15 '21 at 22:07
  • You will have to share more code if you're going to ask question like these. Is there a link? If the compiler is satisfied, clearly you do have these things. If not, maybe the code is, indeed, just broken. – sehe Mar 15 '21 at 22:16