我们让学生在课程中提交练习,同时他们必须遵守一些代码约定.例如,函数名称应该在camelCase中.函数长度不应超过50行(任务很简单,可以划分)等等.我正在寻找一种可以自动检查C/C++(两者都需要)的工具.也就是说,我希望该工具在出现问题时进行投诉,以便学生能够解决问题.到目前为止,我一直无法找到合适的东西.如果这个东西是开源的,可以很容易地根据我们的需求进行配置
以下是使用compareAndSet(在Java中)的无锁队列中的一些代码:
public void enq(T value) {
Node newNode = new Node(value);
while(true) {
Node last = tail.get();
Node next = last.next.get();
if(last != tail.get())
continue; //???
if (next != null) { //improve tail
tail.compareAndSet(last, next);
continue;
}
if (last.next.compareAndSet(null, newNode)) { //update last node
tail.compareAndSet(last, newNode); //update tail
return;
}
}
}
public T deq() throws EmptyException {
while(true) {
Node first = head.get();
Node last = tail.get();
Node next = first.next.get();
if(first != head.get())
continue; //???
if(first == last) …Run Code Online (Sandbox Code Playgroud)