小编Lea*_*jon的帖子

Poco :: Logger线程安全吗?

在我的测试代码中看起来像线程安全.我可以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)

c++ poco-libraries

6
推荐指数
1
解决办法
2189
查看次数

如何在pgSQL中使用数组循环

我想做这样的事情:

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)

arrays postgresql plpgsql

3
推荐指数
2
解决办法
9326
查看次数

如何通过给定的消息类型名称和原始字节为Java Object获取protobuf?

我有字符串和原始字节的消息类型名称。如何通过这些材质创建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)

java protocol-buffers

3
推荐指数
1
解决办法
2278
查看次数

malloc in do while block

我可以将malloc放入do ... while块以确保成功分配吗?

喜欢:

#define STR_SIZE 1024 * 1024
char *str;
do
    str = (char *) malloc(STR_SIZE);
while ( !str );
Run Code Online (Sandbox Code Playgroud)

c malloc

1
推荐指数
1
解决办法
328
查看次数

如何使 JTree 节点在被选择时自动展开?

基本上我希望树节点的选择事件的行为类似于展开事件。

我怎么能这样做呢?

java swing jtree

-2
推荐指数
1
解决办法
653
查看次数

标签 统计

java ×2

arrays ×1

c ×1

c++ ×1

jtree ×1

malloc ×1

plpgsql ×1

poco-libraries ×1

postgresql ×1

protocol-buffers ×1

swing ×1