-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathclose.cxx
More file actions
54 lines (44 loc) · 1.41 KB
/
close.cxx
File metadata and controls
54 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Copyright (c) 2022 ZettaScale Technology
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
//
// Contributors:
// ZettaScale Zenoh Team, <zenoh@zettascale.tech>
//
#include "zenoh.hxx"
using namespace zenoh;
#undef NDEBUG
#include <assert.h>
void test_session_close_in_drop() { auto session = Session::open(Config::create_default()); }
void test_session_close() {
auto session = Session::open(Config::create_default());
session.close();
}
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
void test_session_close_in_background() {
auto session = Session::open(Config::create_default());
bool close_called = false;
auto close_options = Session::SessionCloseOptions::create_default();
close_options.out_concurrent = [&close_called](CloseHandle&& h) {
h.wait();
close_called = true;
};
session.close(std::move(close_options));
if (!close_called) {
exit(-1);
}
}
#endif
int main() {
test_session_close_in_drop();
test_session_close();
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
test_session_close_in_background();
#endif
}