Skip to content

Commit 30376fa

Browse files
committed
.
1 parent d3acd80 commit 30376fa

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

cpp.boost/bounded.buffer/bounded.buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BoundedBuffer
3434

3535
auto push_front(const value_type& item) -> bool
3636
{
37-
unique_lock<mutex> lock(m_mutex);
37+
unique_lock lock(m_mutex);
3838
// 집어넣으려면 공간이 생길때까지 기다려야 한다.
3939
m_while_full.wait(lock,
4040
[this] { return m_unread < m_container.capacity() || m_shutdown; });
@@ -52,7 +52,7 @@ class BoundedBuffer
5252

5353
auto pop_back(value_type* pItem) -> bool
5454
{
55-
unique_lock<mutex> lock(m_mutex);
55+
unique_lock lock(m_mutex);
5656

5757
// 빼내려면 하나이상 존재햐야 한다.
5858
cout << "comsumer waiting ..\n";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required (VERSION 3.30.0)
2+
3+
project (main)
4+
5+
set (CMAKE_CXX_STANDARD 26)
6+
set (CMAKE_CXX_COMPILER clang++)
7+
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
8+
set (HOME $ENV{HOME})
9+
10+
set (SOURCES
11+
main.cpp
12+
)
13+
14+
include_directories (
15+
${HOME}/develop/include
16+
/usr/local/include
17+
/opt/homebrew/include
18+
${CMAKE_CURRENT_SOURCE_DIR}
19+
)
20+
21+
link_directories (
22+
/usr/local/lib
23+
/opt/homebrew/lib
24+
)
25+
26+
add_executable (${CMAKE_PROJECT_NAME}
27+
${SOURCES}
28+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <print>
2+
#include <cstdlib>
3+
#include <memory>
4+
#include <stack>
5+
6+
using namespace std;
7+
8+
template<typename T>
9+
class Handle
10+
{
11+
public :
12+
Handle(T* ptr) : ptr_(ptr) {}
13+
~Handle() { delete ptr_; }
14+
15+
// ...
16+
};
17+
18+
int very_complicated_algorithm(int argc, char* argv[])
19+
{
20+
Handle<int> h(new int(42));
21+
Handle<file> f(new file("test.txt"));
22+
Handle<lock> l(new lock("test.lock"));
23+
Handle<socket> s(new socket("localhost", 8080));
24+
Handle<db> d(new db("test.db"));
25+
Handle<thread> t(new thread([]() {
26+
// Thread code here
27+
}));
28+
Handle<mutex> m(new mutex());
29+
// ..
30+
// ..
31+
32+
{
33+
unique_ptr<int> p0(new int(42));
34+
shared_ptr<stack> p1(new stack());
35+
}
36+
37+
if (1+1 == 2)
38+
{
39+
//
40+
return 0;
41+
}
42+
43+
if (9/0 == 81)
44+
{
45+
//
46+
}
47+
48+
// Do something
49+
50+
return 0;
51+
}
52+
53+
int main()
54+
{
55+
try
56+
{
57+
very_complicated_algorithm(0, nullptr);
58+
}
59+
catch(...)
60+
{
61+
};
62+
63+
return 0;
64+
}

0 commit comments

Comments
 (0)