小编Won*_*ter的帖子

原子<T*>总是锁定自由吗?

在我的MAC OS上,atomic<T*>是免费的.

#include <iostream>
#include <atomic>

int main() {
    std::cout << std::atomic<void*>().is_lock_free() << std::endl;
    return 0;
}

output: 1
Run Code Online (Sandbox Code Playgroud)

我想知道是否atomic<T*>总是免费锁定?

有参考介绍吗?

c++ std c++11 stdatomic

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

什么是 DNS 中的“附加部分”及其工作原理?

当我使用 dig

$ dig www.google.com

; <<>> DiG 9.10.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59489
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 9

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.google.com.            IN  A

;; ANSWER SECTION:
www.google.com.     23  IN  A   69.171.247.71

;; AUTHORITY SECTION:
google.com.     124333  IN  NS  ns4.GOoGLE.cOM.
google.com.     124333  IN  NS  ns1.GOoGLE.cOM.
google.com.     124333  IN  NS …
Run Code Online (Sandbox Code Playgroud)

dns bind

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

为什么'EINTR'未申报?

我列入<error.h>.

#include <error.h>
#include <unistd.h>

ssize_t rio_readn(int fd, void *buf, size_t n)
{
    size_t nleft = n;
    char *rbuf = buf;
    while(nleft > 0)
    {
        int nread = read(fd, rbuf, nleft);
        if(nread < 0)
        {
            if(error == EINTR)
                nread = 0;
            else
                return -1;
        }
        else if(nread == 0)
            break;
        nleft -= nread;
        rbuf += nread;
    }
    return n - nleft;
}
Run Code Online (Sandbox Code Playgroud)

c unix io

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

标签 统计

bind ×1

c ×1

c++ ×1

c++11 ×1

dns ×1

io ×1

std ×1

stdatomic ×1

unix ×1