在我的测试代码中看起来像线程安全.我可以Poco::Logger在多线程程序中使用吗?
static Poco::Logger *pLogger;
class MyRunnable : public Poco::Runnable {
private:
std::string _name;
Poco::Random _rnd;
public:
void setName(std::string name) {
_name = name;
}
void run() {
for (int i=0; i<200; i++) {
pLogger->information("info from: " + _name);
_rnd.seed(_rnd.next(65532) * _name.size());
Poco::Thread::sleep(_rnd.next(13) + 1);
}
}
};
Run Code Online (Sandbox Code Playgroud)
这里是测试主要:
int
main ( int argc, char *argv[] )
{
Poco::Thread thr1, thr2, thr3;
MyRunnable *pMyR1 = new MyRunnable(),
*pMyR2 = new MyRunnable(),
*pMyR3 = new MyRunnable();
pMyR1->setName("r1");
pMyR2->setName("ra2");
pMyR3->setName("runable3");
Poco::FormattingChannel …Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
CREATE OR REPLACE FUNCTION ff(int, text) RETRUNS integer AS $$
DECLARE
r text;
BEGIN
FOR r IN SELECT string_to_array($2, ',')
LOOP
INSERT INTO test(i, t) VALUES($1, r);
END LOOP;
RETRUN 0;
END
$$LANGUAGE pgsql;
Run Code Online (Sandbox Code Playgroud)
我希望用SELECT ff(3, 'a,b');这个功能可以做到
INSERT INTO test(i, t) VALUES(3, 'a');
INSERT INTO test(i, t) VALUES(3, 'b');
Run Code Online (Sandbox Code Playgroud) 我有字符串和原始字节的消息类型名称。如何通过这些材质创建Java对象?原型
pakage foo;
message Bar {
required int32 id = 1;
required string name = 2;
}
Run Code Online (Sandbox Code Playgroud)
TestMain.java
foo.Bar bar = foo.Bar.newBuilder()
.setId(1).setName("foobar").build();
byte[] rawbytes = bar.toByteArray();
String typeName = bar.getDescriptorForType().getFullName();
foo.Bar b = (foo.Bar) howTo(rawbyte, typeName);
Run Code Online (Sandbox Code Playgroud) 我可以将malloc放入do ... while块以确保成功分配吗?
喜欢:
#define STR_SIZE 1024 * 1024
char *str;
do
str = (char *) malloc(STR_SIZE);
while ( !str );
Run Code Online (Sandbox Code Playgroud)