갬장장이
'lang' 카테고리의 글 목록

lang

lang/.NET

SynchronizationContext

개인 기록용 포스트입니다, 잘못된 내용이 있을 수 있습니다. Akka .NET의 SynchronizedDispatcher를 공부하던 중 해당 기능이 내부적으로 SynchronizationContext를 사용하고 있다고 해서 자세히 찾아보게 되었다. using System; using System.Threading; using System.Threading.Tasks; class Program { static void Main() { // Simulating a UI context capture var synchronizationContext = SynchronizationContext.Current; // UI triggers an asynchronous operation ButtonClickHandle..

lang/.NET

Akka.NET

https://petabridge.com/blog/akkadotnet-what-is-an-actor/

lang/erlang, elixir

BEAM concurrency model

SEP 29, 2019 • JAVIER GARCÍA The first question that arises when we talk about concurrency is what is concurrency? When talking about concurrency, it’s important not to confuse concurrency with parallelism. While concurrency implies that two pieces of code are executed in different contexts, it doesn’t necessarily imply that they are executed at the same time. Parallelism does. If two fragments ..

lang/c++

가상 소멸자

1) Animal 클래스와 Cat 클래스가 존재한다. Cat 클래스를 Animal 클래스 포인터로 가리킨 상태에서 (Upcasting) 그대로 삭제하게 되면 ~Animal만 호출되고 ~Cat은 호출되지 않아 Cat의 내용물이 모두 해제되지 않는 메모리 릭이 발생할 수 있다. 2) 이를 해결하기 위해서는 Animal 클래스의 소멸자를 virtual로 선언해주면 된다. 3) 하지만 모든 클래스의 소멸자에 무조건 virtual을 붙여주는 것은 좋지 않다. 이유는 virtual을 붙이는 순간 해당 객체는 vtable을 가리키는 vptr을 내부적으로 가지게 되고, 이는 즉 다시 말해 객체의 크기가 커지는 것을 의미한다. 해당 객체의 개수와 빌드 아키텍처에 따라 고작 virtual 하나를 붙였을 뿐인데 불필요한 메..

lang/c++

템플릿 사용 시 LNK1120 "확인할 수 없는 외부 참조" 발생

분명 필요한 헤더 파일을 전부 include 했지만 계속 해당 오류가 발생하는 경우가 있다. 원인: 템플릿을 .h와 .cpp로 분리해서 작성할 경우 발생하는 에러이다. 해결 방법: 1) 템플릿을 애초에 .cpp로 분리하지 않고 .h에 구현부까지 작성한다 2) 혹은 cpp 구현부 하단부에 가능한 템플릿 목록을 미리 선언해 놓는다 3) 혹은 .cpp를 같이 include 한다 참고: https://ansohxxn.github.io/cpp/chapter13-2/

lang/c++

std::shared_ptr은 thread-safe한가?

1) shared_ptr의 레퍼런스 카운팅은 thread safe하다 2) 즉 shared_ptr의 control block(레퍼런스 카운트 정보를 담고 있는 부분, 참고)은 thread safe 하다 3) 그러나, shared_ptr 자체가 가리키는 객체는 thread safe하지 않다 4) C++20부터는 atomic_shared_ptr의 사용이 가능하다// Thread-safe std::shared_ptr ptr = std::make_shared(4); for (auto i =0;i

lang/c++

atan, atan2

https://spiralmoon.tistory.com/entry/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D-%EC%9D%B4%EB%A1%A0-%EB%91%90-%EC%A0%90-%EC%82%AC%EC%9D%B4%EC%9D%98-%EC%A0%88%EB%8C%80%EA%B0%81%EB%8F%84%EB%A5%BC-%EC%9E%AC%EB%8A%94-atan2 [프로그래밍 이론] 두 점 사이의 절대각도를 재는 atan2 두 점 사이의 절대각도를 재는 atan2 프로그래밍 언어에서 역탄젠트를 계산하는 함수 atan2의 특징을 알아보자 아크탄젠트란? 아크탄젠트(arctangent)는 역탄젠트라고도 하며 탄젠트의 역함수이다. spiralmoon.tistory.com convex..

lang/c++

std::iterator, std::advance

std::iterator https://ansohxxn.github.io/stl/chapter16-2/ [C++ 표준] STL 반복자(+ 반복자의 종류 Iterator Category 인프런에 있는 홍정모 교수님의 홍정모의 따라 하며 배우는 C++ 강의를 듣고 정리한 필기입니다. 😀 🌜 [홍정모의 따라 하며 배우는 C++]강의 들으러 가기! ansohxxn.github.io iterator를 별도로 사용하는 이유? 1) 만약 반복문 도중 무언가를 삭제해야 할 일이 있다면 iterator로 지우고 2칸 뛰고 등의 방식으로 처리해줄 수 있음. 이는 auto로는 불가능함! 2) vector, array와 같이 [index]꼴의 접근이 불가능한 자료구조일 경우 별도로 iterator를 정의해주어야 할 수도 있음..