草庐IT

run_in_thread

全部标签

C++标准写法: Does "through all iterators in the range" imply sequentiality?

ThisSOquestion引发了关于std::generate和标准做出的保证的讨论。特别是,你能否使用具有内部状态的函数对象并依赖于generate(it1,it2,gen)来调用gen(),将结果存储在*it,再调用gen(),存入*(it+1)等,还是可以从后面开始,比如?标准(n3337,§25.3.7/1)是这样说的:Effects:Thefirstalgorithminvokesthefunctionobjectgenandassignsthereturnvalueofgenthroughalltheiteratorsintherange[first,last).Thes

c++ - 安装摩西翻译软件。错误消息 : "ld: library not found for -lboost_thread"

我正在使用Xcode6.1的MacOSX10.9.5上安装Moses翻译软件。Theinstructionssay我需要安装g++和Boost。执行此操作后,我将gitclone,“cd”到目录中,然后键入./bjam-j8。首先,我确认我具备先决条件。首先,g++(我只是单击TAB以查看可用的内容):$g++g++g++-4.9然后boost:$brewinstallboostWarning:boost-1.56.0alreadyinstalled然后我尝试安装:$./bjam-j8Tip:installtcmallocforfasterthreading.SeeBUILD-INST

c++ - std::thread 在使用参数创建时抛出访问冲突异常?

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭6年前。Improvethisquestion我正在使用VS2015,在使用std::thread时遇到一个非常奇怪的问题。voidKlass::myfunc(inta,intb){std::cout它在Debug模式下运行良好,但当我转到Release模式时抛出“访问冲突异常”。此外,如果我尝试将

c++ - C 编译 : error: stray '\4' in program ; octal flow?

正在尝试编译大量.c文件(1)文件编译正常,使用cccc-Wall-Wextra-Wunreachable-code-ggdb-O0*.c(2)然后,我需要根据最终输出创建一个静态库,以在C++程序中使用。所以我这样做:arcruliborientdb-c.a*.o(3)工作正常。但是,当我编译包含第1行库的c++程序testme.cpp时(line1oftestme.cpp)#include"liborientdb-c.a"编译步骤:cctestme.cpp我收到这个错误:liborientdb-c.a:117:22:error:stray'\3'inprogramliborient

c++ - 跨内核线程迁移后是否可以强制重新加载 thread_local 变量?

我在内核和线程之上实现用户线程并观察到,当用户线程在内核线程之间迁移时,thread_local变量会从先前的内核位置读取,即使变量也被标记作为volatile。由于编译器仅将用户级swapcontext视为函数调用,因此下面的示例演示了简单函数调用的问题。#includestructFoo{intx;inty;};__threadFoo*volatilefoo;voidbar(){asm("nop");}voidf(){foo->x=5;bar();asmvolatile("":::"memory");//Wedesireasecondcomputationoftheaddresso

c++ - decltype((void)T{}) in template Partial Specialization 不推导?

templatestructTest{staticconstintvalue=0;};templatestructTest{staticconstintvalue=2;};templatestructTest{staticconstintvalue=1;};intmain(){cout::valuegcc/clang上的代码都出现错误:模棱两可,但是将decltype更改为void_t是可以的。为什么? 最佳答案 对我来说,这看起来像是一个编译器错误:你真的需要T{}的副作用吗??decltype((void)T{})的整体构造应该

c++ - boost::threads - 如何正常关机?

我正在尝试通过使用boost:threads而不是我们自己的Win32线程包装器来提高C++应用程序的可移植性,而优雅的线程终止问题(再次)又浮出水面。在纯win32上,我使用QueueUserAPC来“中断”线程抛出一个“thread_interrupt”异常,导致所有RAII对象在退出时被清理,asdescribedhere.任何“可警报”操作系统功能都可以通过这种方式中断,因此互斥等待、sleep、串行和套接字I/O等都是可能的中断点。但是,boost:mutexes等在win32上不会被QueueUserAPC“警告”——它们调用诸如Sleep(n)而不是SleepEx(n,t

C++ 64 位 - 无法读取符号 : Archive has no index; run ranlib to add one

我正在尝试使用静态库在LinuxRHAS5.364位上生成一个非常简单的二进制文件。test1.cpp,生成的.o将被嵌入到静态库中。voidctest1(int*i){*i=5;}和prog.cpp#includevoidctest1(int*);intmain(){intx;ctest1(&x);printf("Valx=%d\n",x);return0;}如果我用32位编译,没问题:--(0931:Wed,06Apr11:$)--g++-m32-Wall-cctest1.cpp--(0931:Wed,06Apr11:$)--filectest1.octest1.o:ELF32-b

c++ - 振奋 spirit : What type names should be used for the built in terminals?

我正在重构一个类型系统(类型模型),它使用spirit进行字符串序列化。我正在使用类型特征的编译时建模构造。templatetype_traits{typedefboost::spirit::qi::int_parserstring_parser;}templatetype_traits{typedefboost::spirit::ascii::stringstring_parser;}在这个例子中,我展示了原始解析器,但我希望也加入规则。int4类型有效,但这是因为(home/qi/numeric/int.hpp+27):namespacetag{templatestructint_

c++ - 使用线程池进行模拟: boost-thread and boost-asio

我想使用boost::asio来设置线程池。我的问题是:如何将特定数据附加到创建的每个线程,以及如何管理单独的输出?更具体地说,我编写了一个类Simulation,它通过一种在输入中获取一些参数的方法来执行模拟。该类包含计算所需的所有数据。由于数据不是太大,我想复制它以便在池的每个线程中使用类Simulation的不同实例。我想做这样的事情:(这里解释了如何设置线程池:SO和Asiorecipes)classParallelSimulation{public:staticconststd::size_tN=10;protected:std::vector>simuInst;//Ncop