General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
724 B

#include <gp/algorithm/foreach.hpp>
#include <gp/allocator/buddy.hpp>
#include <gp/array.hpp>
#include <gp/enveloppe/cbor.hpp>
#include <gp/vfs/system.hpp>
#include "test_scaffold.h"
#include <atomic>
struct channel_test : public test_scaffold {
channel_test() {
name = __FILE__ ":1";
}
virtual int run() {
auto store = std::make_unique<gp::array<char, 4096*512>>();
gp::buddy<> alloc{&*store->begin(), store->size()};
gp::system sys{alloc, 1};
std::atomic_int a = 0;
sys.spawn(gp::function<void()>{[&](){
a.fetch_add(1);
}, alloc});
sys.run_once();
gp_config::assertion(a.load(), "did not increment (aka run the fiber)");
return 0;
}
};
append_test dummy_hke41r43(new channel_test{});