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.

34 lines
724 B

пре 4 година
  1. #include <gp/algorithm/foreach.hpp>
  2. #include <gp/allocator/buddy.hpp>
  3. #include <gp/array.hpp>
  4. #include <gp/enveloppe/cbor.hpp>
  5. #include <gp/vfs/system.hpp>
  6. #include "test_scaffold.h"
  7. #include <atomic>
  8. struct channel_test : public test_scaffold {
  9. channel_test() {
  10. name = __FILE__ ":1";
  11. }
  12. virtual int run() {
  13. auto store = std::make_unique<gp::array<char, 4096*512>>();
  14. gp::buddy<> alloc{&*store->begin(), store->size()};
  15. gp::system sys{alloc, 1};
  16. std::atomic_int a = 0;
  17. sys.spawn(gp::function<void()>{[&](){
  18. a.fetch_add(1);
  19. }, alloc});
  20. sys.run_once();
  21. gp_config::assertion(a.load(), "did not increment (aka run the fiber)");
  22. return 0;
  23. }
  24. };
  25. append_test dummy_hke41r43(new channel_test{});