堆栈的顶存储在result 中,使用CAS把top位置更新为 top->next并返回适当的数据。
The top of the stack is stored in result, and you use CAS to update the top location with top-<next and return the appropriate data.
这样,即使线程b在线程A试图弹出数据的同时修改了堆栈顶,也可以确保不会跳过堆栈中的元素。
With this arrangement, even if Thread B has modified the top while Thread a tries to pop, you're sure that no elements in the stack are skipped.
push方法观察当前最顶的节点,构建一个新节点放在堆栈上,然后,如果最顶端的节点在初始观察之后没有变化,那么就安装新节点。
The push method observes the current top node, constructs a new node to be pushed on the stack, and then, if the topmost node has not changed since the initial observation, installs the new node.
第20行访问栈顶(栈顶的索引为- 1)作为lua字符串,打印消息,然后从堆栈中删除该值。
Line 20 accesses the top of the stack (the top of the stack has an index of -1) as a Lua string, prints the message, and then removes the value from the stack.
第20行访问栈顶(栈顶的索引为- 1)作为lua字符串,打印消息,然后从堆栈中删除该值。
Line 20 accesses the top of the stack (the top of the stack has an index of -1) as a Lua string, prints the message, and then removes the value from the stack.
应用推荐