| | 1 | // -*- coding: utf-8 -*- |
| | 2 | |
| | 3 | #include <mil/PrecompiledHeaders.h> |
| | 4 | #include <mil/Thread.h> |
| | 5 | #include <mil/Memory.h> |
| | 6 | #include "Test.h" |
| | 7 | |
| | 8 | using namespace mil::pool; |
| | 9 | |
| | 10 | class ThreadIdAnd; |
| | 11 | |
| | 12 | template <int Bytes> |
| | 13 | class Memory { |
| | 14 | class { |
| | 15 | uint32_t data; |
| | 16 | public: |
| | 17 | uint16_t getThreadId() { |
| | 18 | } |
| | 19 | uint16_t getBlockCount() { |
| | 20 | } |
| | 21 | void set(uint16_t thread_id, uint16_t block_count) { |
| | 22 | } |
| | 23 | } header; |
| | 24 | char body[Bytes]; |
| | 25 | }; |
| | 26 | |
| | 27 | class Producer { |
| | 28 | }; |
| | 29 | |
| | 30 | class Consumer { |
| | 31 | }; |
| | 32 | |
| | 33 | int next(int *phase, int count) { |
| | 34 | int result = *phase % count; |
| | 35 | *phase = *phase - result; |
| | 36 | return result; |
| | 37 | } |
| | 38 | |
| | 39 | #define check(x) if (!x) { \ |
| | 40 | printf("phase%d: %s error\n", phase, #x); \ |
| | 41 | } |
| | 42 | |
| | 43 | void test_pool2a(int phase, bool* result) { |
| | 44 | *result = true; |
| | 45 | int bytes = next(&phase, 200); |
| | 46 | if (!phase) { |
| | 47 | *result = false; |
| | 48 | return; |
| | 49 | } |
| | 50 | |
| | 51 | { // データが確保されているか軽くチェック |
| | 52 | mil::thread::id_t thread_id = 5; |
| | 53 | Producer p(thread_id); |
| | 54 | |
| | 55 | } |
| | 56 | |
| | 57 | |
| | 58 | return true; |
| | 59 | } |
| | 60 | |
| | 61 | QT_TEST(test_pool2a) { |
| | 62 | for (int phase = 0; ; phase++) { |
| | 63 | bool result = false; |
| | 64 | test_pool2a(phase, &result); |
| | 65 | if (!result) { |
| | 66 | break; |
| | 67 | } |
| | 68 | } |
| | 69 | } |
| | 70 | |