acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
synchronization_array.h
1#pragma once
2
3
4//#include "synchronization_object.h"
6#include "acme/prototype/collection/address_array.h"
7
8
9//#ifdef WINDOWS
10using hsynchronization_array_base = ::address_array_base < hsynchronization >;
11using hsynchronization_array = ::array_particle < hsynchronization_array_base >;
12//#endif
13
14
15template < typename T, ::collection::count t_iCount >
16class fixed_raw_array
17{
18public:
19
20
21 T m_ta[t_iCount];
22
23 fixed_raw_array()
24 {
25 ::memory_set(m_ta, 0, sizeof(T) * t_iCount);
26
27 }
28 fixed_raw_array(const fixed_raw_array & a)
29 {
30
31 ::memory_copy(m_ta, a.m_ta, sizeof(T) * t_iCount);
32
33 }
34 ::collection::count size() const { return t_iCount; }
35 T & operator[](::collection::index i) { return m_ta[i]; }
36 const T & operator[](::collection::index i) const { return m_ta[i]; }
37 void erase_at(::collection::index i, ::collection::count s)
38 {
39 ::memory_transfer(&m_ta[i], &m_ta[i + 1], s - i - 1);
40 }
41 fixed_raw_array & operator = (const fixed_raw_array & a)
42 {
43 if (this != &a)
44 {
45
46 ::memory_copy(m_ta, a.m_ta, sizeof(T) * t_iCount);
47 }
48 return *this;
49 }
50};
51
52class CLASS_DECL_ACME synchronization_array :
53 virtual public ::particle
54{
55protected:
56
57
58 ::pointer_array < subparticle > m_subparticlea;
59
60 hsynchronization_array m_hsynchronizationa;
61 fixed_raw_array < ::u8, MAXIMUM_SYNCHRONIZING_OBJECTS > m_uaIndexes;
62
63public:
64
65
66
67 synchronization_array();
68 synchronization_array(const ::synchronization_array & array);
69 ~synchronization_array() override;
70
71
72 void clear();
73
74
75
76 bool add_item(::subparticle * pparticle);
77
78 inline bool add(::subparticle* pparticle) { return add_item(pparticle); }
79
80 bool add(const synchronization_array & waitablea);
81
82 void erase(::subparticle* pparticle);
83
84 void erase(::collection::index index);
85
86 ::e_status wait() override;
87
88 virtual ::e_status wait(const class time & timeWait, bool waitForAll = true, ::u32 uWaitMask = 0);
89
90 virtual void unlock_item(::collection::index index);
91
92 virtual void unlock_item(::collection::index index, ::i32 lCount, ::i32 * pPrevCount = nullptr);
93
94 virtual void contains(const ::e_status & result) const;
95
96 synchronization_array & operator = (const synchronization_array & synca);
97
98 hsynchronization * data() {return m_hsynchronizationa.data(); }
99 ::collection::count size() const { return m_hsynchronizationa.size(); }
100 bool is_empty() const { return this->size() <= 0; }
101 ::subparticle * at(::collection::index i) const { return m_subparticlea.ptr_at(i); }
102};
103
104
105
Definition e_status.h:30
Definition subparticle.h:78
Definition aaa_time.h:13