|Coding| C++ smart pointers: unique_ptr, shared_ptr, strong pointer(sp, Android)

In C++, smart pointers, unique_ptr and shared_ptr, are very common.
If you develop on Android, you may have seen strong pointer(sp), it is also a smart pointer.
Some notes about those pointers.

strong pointer in Android, can be saw as shared_ptr.
shared_ptr has a counter to record who is using this pointer in order to prevent dangerous pointer managements.

|Linux| IPC methods introduce, comparison and examples

Threads can share resource with each other, but processes can’t.
Communicating to another processes should use IPC methods.
Common IPC methods in Linux are pipe, shared memory, signal, message queue and domain socket.

This article will introduce shared memory and message queue.
The most efficiency is shared memory (than domain socket).

|Linux| eBPF – BCC config and test

BCC := BPF Compiler Collection (ref. https://lwn.net/Articles/742082/ )

Originally, BPF is a tool for analyzing network traffic. After years, eBPF has been improved to be used for non-networking purposes, such as for attaching eBPF programs to various tracepoints. wiki

Comparing with XDP (driver layer tool for network, XDP test), BCC provides a tool chain for high level languages.
With this tool, developers can implement their own analyzing tools to manage BPF tools by Python, Lua or other high level languages.

This article will show how to config and run a test code.

|Design| Synchronous v.s. Asynchronous

This article will distinguish Synchronous and Asynchronous.
I just want to say forget your Chinese ……

中文DefinitionAPI and callbackBlock
Synchronous同步While the API receiving the callback remains on the stack, you would expect that the callback had been invoked on each element.in the same threadBlock
Asynchronous非同步Callback is invoked after a function returns, or at least on another thread’s stack.
while the API receiving the callback remains on the stack, the callback may not have been called, since it’s waiting for the connection to complete.
multi-threadnon-block

Therefore, if you want to design asynchronous APIs, keep your threads safety.


這邊很常有個謬誤:
非同步,中文看起來很像是:排排隊,一個做完再做下一件事。
同步,看起來很像是:有兩個 thread,一起做事。
事實上,非常抱歉,以英文及程式的定義來說剛好反過來!


Ref.
Good article:
https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/
Translation:
https://www.eebreakdown.com/2015/09/callback-apis.html?m=1

https://blog.huli.tw/2019/10/04/javascript-async-sync-and-callback/
https://www.ithome.com.tw/node/74544