小编Syl*_*sne的帖子

Boost :: Thread API中的CPU亲和力

是否可以在Boost线程中设置CPU亲和力((即,将每个线程设置为在不同的CPU上运行)?您是否可以对此提出任何教程/文档?在以下示例中,除了以下线程外,Google搜索不会返回太多信息(boost-bind_processor.v1.tar.gz)不再存在于文件服务器中。

http://lists.boost.org/boost-users/2009/02/45172.php

c++ linux cpu multithreading boost-thread

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

发送UDP数据包并从C中的路由器接收ICMP响应

我正在尝试编写一个C程序,它将UDP数据包发送到给定的IP地址,并等待路由器的ICMP响应,告知生存时间已到期.它保持非常简单,因为我只想先了解机制.我需要的是有人检查我的代码,提供有关错误和缺失的反馈.我对C编程非常缺乏经验,但我必须将其作为一项任务 - 让我尽力理解它...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/ip.h> 

// The packet length
#define PCKT_LEN 8192 

// Source IP, source port, target IP, target port from the command line arguments
int main(int argc, char *argv[])
{
    int send, recv, resp;
    int ttl = 1; // Time to live
    char buffer[PCKT_LEN];

    // Destination address
    struct sockaddr_in dst;

    // ICMP Response
    struct msghdr icmp;

    memset(buffer, 0, PCKT_LEN);

    // Create a raw socket with UDP protocol
    if ((send = socket(PF_INET, SOCK_DGRAM, …
Run Code Online (Sandbox Code Playgroud)

c sockets udp raw-sockets icmp

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

一个alloc,retainCount == 2

我有以下代码:

NSLog(@"%d", [chart retainCount]);

self.chart = [[BNPieChart alloc] initWithFrame:self.view.frame];
NSLog(@"%d", [chart retainCount]);
Run Code Online (Sandbox Code Playgroud)

终端显示:

[Session started at 2011-03-28 11:09:46 +0200.]
2011-03-28 11:09:51.008 Finance[35111:207] 0

2011-03-28 11:09:51.010 Finance[35111:207] 2
Run Code Online (Sandbox Code Playgroud)

据我所知,retainCount应该等于1,而不是2.

iphone memory-management

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

向量<char>的输入流 - 向量迭代器不可解除引用

首先,我是来自Java的C++新手.我想做一件简单的事情:使用URDL-libs从Web加载图片并将其保存到char-vector.加载图像工作正常,我能够将其保存到磁盘,但当我尝试将其加载到char-vector时,我在运行时收到此错误:

Expression: vector iterator not dereferencable
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

urdl::istream inputStream( url );
if( inputStream )
{
    inputStream >> std::noskipws;
    istream_iterator<char> inputStreamIterator( inputStream ), inputStreamEnd;
    string dateiname = "test.png";
    vector<char> imageVector;

    ofstream outputStream( dateiname, ios_base::binary );
    ostream_iterator<char> outputStreamIterator(outputStream);
    copy( inputStreamIterator, inputStreamEnd,  imageVector.begin());
}
Run Code Online (Sandbox Code Playgroud)

c++ boost vector stream

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

编译Doom 3时找不到/usr/lib/libz.a

我正在尝试编译新发布的Doom 3源代码,但得到了错误:

scons: *** [build/debug/core/sys/scons/doom] Source `/usr/lib/libz.a'
    not found, needed by target `build/debug/core/sys/scons/doom'.
scons: building terminated because of errors. 
Run Code Online (Sandbox Code Playgroud)

有谁知道我应该怎么做?(我在Ubuntu 11.04上)

c++ linux

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

有管道,叉子,dup2的问题

我使用管道,fork,dup2来实现"ls | 更多"或"ls | 排序"等我在这里无法理解这个问题.当我运行我的程序时,我收到此错误:

./a.out  
Missing filename ("less --help" for help)
Run Code Online (Sandbox Code Playgroud)

为什么我会"少"?

这段代码有什么问题?如果我再次将"更多"更改为"ls",则可以正常工作.我的意思是,它就像做ls | LS.

#define STDIN 0
#define STDOUT 1

int main()
{
   int fd[2];
   int pid;
   char *lschar[20]={"ls",NULL};
   char *morechar[20]={"more",NULL};
   pid = fork();
   if (pid == 0) {
   /* child */
     int cpid;
     cpid = fork();
     if(cpid == 0) {
       //printf("\n in ls \n");
       pipe(fd);
       dup2(fd[1], STDOUT);
       close(fd[0]);
       close (fd[1]);
       execvp("ls",lschar);
     } else if(cpid>0) {
       waitpid(cpid, NULL,0);
       dup2(fd[0],STDIN);
       close(fd[0]);
       close(fd[1]);
       execvp("more", morechar);
     }
   } else if (pid …
Run Code Online (Sandbox Code Playgroud)

c linux fork pipe

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

Hashcode值相同

为什么hashcode值相同?

public static void main(String args[])
{
    String s1="abc";
    String s2=new String("abc");
    System.out.println("Hashcode s1-:"+ s1.hashCode());
    System.out.println("Hashcode s2-:"+ s2.hashCode());
    if(s1==s2){
        System.out.println("==true:");
    } 
}
Run Code Online (Sandbox Code Playgroud)

产量

Hashcode s1-:96354
Hashcode s2-:96354
Run Code Online (Sandbox Code Playgroud)

java

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

方法的jni签名

我的java方法包含一个函数

 public static void downLoadProfileImage(String url, String fileName,  int tag, int from)
Run Code Online (Sandbox Code Playgroud)

我收到JNI签名错误:

if (JniHelper::getStaticMethodInfo(jniMethodInfo, packageName.c_str(), "downLoadProfileImage", "(Ljava/lang/String;Ljava/lang/String;I;I;)V")) 
Run Code Online (Sandbox Code Playgroud)

如果我只保留两个字符串,一切正常.但是有两个整数会引发错误?我究竟做错了什么?

c++ java java-native-interface

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