Rvalue reference는 C++11에서 처음 소개된 기능으로 다소 이해하기 어려운 구조1로 되어있다. Each C++ expression (an operator with its operands, a literal, a variable name, etc.) is characterized by two independent properties: a type and a value category. Each expression has some non-reference type, and each expression belongs to exactly one of the three primary value categories: prvalue, xvalue, and lvalue2.
C++의 RValue 참조 및 Move 생성자 개념을 간단한 예제3를 통하여 정리해보았다.
Rust 프로그래밍에서 concurrency 모델의 핵심 메커니즘을 비교적 간단한 소스 코드를 통하여 단계별로 정리해보았다1. Go(lang)에서 goroutine, channel을 사용하여 함수와 메소드의 동시성을 구현할 수 있게 해주는 것2처럼 Rust에서는 ‘Concurrency, Threads, Channels, Mutex and Arc’로 동시성을 구현할 수 있다.
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::Duration;
fn main() {
let v = vec![1, 2, 3];
let handle = thread::spawn(move || {
println!("vector: {:?}", v);
});
// - error : value borrowed here after move
// println!("{:?}", v);
// - channel을 이용하여 해결
handle.join().unwrap();
}
C#에서 ‘using’ 키워드는 네임스페이스에서 유형을 가져오고 이에 대한 별칭을 만드는 지시문에 사용되는 것 외에 IDisposable 인터페이스에 사용하는 ‘using’이다1. 이것은 닷넷에 사용한 자원을 제거하도록 유도한다. 특히 C# 8버전에서는 ‘using’을 single line으로 구성할 수 있다2.
public class AResource : IDisposable
{
public void UseIt() => Console.WriteLine($"{nameof(UseIt)}");
public void Dispose()
{
Console.WriteLine($"Dispose {nameof(AResource)}");
GC.SuppressFinalize(this);
}
}