我正在研究嵌入式系统,因此代码大小是一个问题.使用标准库将我的二进制大小提高了大约60k,从40k到100k.我想使用std :: function,但我不能证明它是60k.是否有可以使用的独立实现或类似的东西?我正在使用它在c ++ 11中使用绑定变量隐式地在成员函数中强制转换lambdas.
我目前有两个线程是生产者和消费者.生成器是一种静态方法,它在Deque类型的静态容器中插入数据,并通过boost::condition_variable在deque对象中插入对象来通知使用者.然后,使用者从Deque类型中读取数据并将其从容器中删除.两个线程使用进行通信boost::condition_variable
这是正在发生的事情的摘要.这是消费者和生产者的代码
//Static Method : This is the producer. Different classes add data to the container using this method
void C::Add_Data(obj a)
{
try
{
int a = MyContainer.size();
UpdateTextBoxA("Current Size is " + a);
UpdateTextBoxB("Running");
MyContainer.push_back(a);
condition_consumer.notify_one(); //This condition is static member
UpdateTextBoxB("Stopped");
}
catch (std::exception& e)
{
std::string err = e.what();
}
}//end method
//Consumer Method - Runs in a separate independent thread
void C::Read_Data()
{
while(true)
{
boost::mutex::scoped_lock lock(mutex_c);
while(MyContainer.size()!=0)
{
try
{
obj …Run Code Online (Sandbox Code Playgroud)