小编cha*_*eng的帖子

在输出文件中找不到protobuf服务

我在proto文件中定义了一个rpc服务,但我在输出java文件中找不到任何接口或方法.

$ protoc -v 
libprotoc 2.5.0
Run Code Online (Sandbox Code Playgroud)

原型文件:

service EchoService {
    rpc Echo (Person) returns (Person);
}
Run Code Online (Sandbox Code Playgroud)

编译脚本:

#!/bin/bash

for file in `find src/main/proto -name "*.proto"`; do
    protoc --proto_path=src/main/proto --java_out=src/main/java/ $file
done
Run Code Online (Sandbox Code Playgroud)

java protocol-buffers

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

究竟是UNSAFE.compareAndSwapObject的作用

我在阅读JDK ConcurrentLinkedQueue时发现UNSAFE.compareAndSwapObject非常奇怪.(CLQ类是来自ConcurrentLinkedQueue的副本,以便于调试......)

当我向ConcurrentLinkedQueue提供第一项时.

代码:ConcurrentLinkedQueue.class offer()

public boolean offer(E e) {
    checkNotNull(e);
    final Node<E> newNode = new Node<E>(e);

    for (Node<E> t = tail, p = t;;) {
        Node<E> q = p.next;
        if (q == null) {
            // p is last node
            if (p.casNext(null, newNode)) {
                // Successful CAS is the linearization point
                // for e to become …
Run Code Online (Sandbox Code Playgroud)

java java.util.concurrent

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