Skip to content

Commit 83a1e84

Browse files
committed
test
1 parent a8fc1e3 commit 83a1e84

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/geode/basic/database.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939

4040
namespace
4141
{
42-
constexpr auto DATA_EXPIRATION = std::chrono::minutes( 5 );
42+
constexpr auto DATA_EXPIRATION = std::chrono::minutes( 1 );
43+
int count{ 0 };
4344
} // namespace
4445

4546
namespace geode
@@ -48,21 +49,21 @@ namespace geode
4849
{
4950
public:
5051
Storage( std::unique_ptr< geode::Identifier >&& data )
51-
: data_{ std::move( data ) }
52+
: data_{ std::move( data ) }, count_{ count++ }
5253
{
5354
}
5455

5556
~Storage()
5657
{
57-
DEBUG( "~Storage" );
58+
Logger::debug( count, " -> ", "~Storage" );
5859
std::unique_lock< std::mutex > locking{ lock_ };
5960
terminate_ = true;
60-
DEBUG( nb_calls_ );
6161
condition_.notify_all();
6262
condition_.wait( locking, [this] {
63+
Logger::debug( count, " -> ", nb_calls_ );
6364
return nb_calls_ == 0;
6465
} );
65-
DEBUG( "~Storage end" );
66+
Logger::debug( count, " -> ", "~Storage end" );
6667
}
6768

6869
bool expired() const
@@ -113,26 +114,26 @@ namespace geode
113114
{
114115
last_used_ = std::chrono::system_clock::now();
115116
async::spawn( [this] {
116-
DEBUG( "wait" );
117+
Logger::debug( count, " -> ", "wait" );
117118
std::unique_lock< std::mutex > locking{ lock_ };
118119
nb_calls_++;
119-
DEBUG( nb_calls_ );
120-
DEBUG( "wait 2" );
120+
Logger::debug( count, " -> ", "wait 2" );
121121
if( !condition_.wait_for( locking,
122122
DATA_EXPIRATION + std::chrono::seconds( 1 ), [this] {
123+
Logger::debug( count, " -> ", terminate_ );
123124
return terminate_;
124125
} ) )
125126
{
126-
DEBUG( "wait in" );
127+
Logger::debug( count, " -> ", "wait in" );
127128
if( !terminate_ && unused()
128129
&& std::chrono::system_clock::now() - last_used_
129130
> DATA_EXPIRATION )
130131
{
131-
DEBUG( "wait reset" );
132+
Logger::debug( count, " -> ", "wait reset" );
132133
data_.reset();
133134
}
134135
}
135-
DEBUG( "wait out" );
136+
Logger::debug( count, " -> ", "wait out" );
136137
nb_calls_--;
137138
condition_.notify_all();
138139
} );
@@ -146,6 +147,7 @@ namespace geode
146147
std::chrono::time_point< std::chrono::system_clock > last_used_;
147148
std::mutex lock_;
148149
std::condition_variable condition_;
150+
int count_;
149151
};
150152

151153
class Database::Impl

0 commit comments

Comments
 (0)