acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
manual_reset_happening.h
1//*****************************************************************************
2//
3// Class: manual_reset_happening
4// Author: Kenny Kerr
5// Date created: 10 April 2004
6// Description: Notifies one or more waiting threads that an happening has
7// occurred.
8//
9//*****************************************************************************
10
11
12#pragma once
13
14
15#include "happening.h"
16
17
18// #define DECLARE_REUSABLE(TYPE) \
19// TYPE * m_pnext; \
20// ::factory_item::reusable_factory_item < TYPE, TYPE > * m_pfactory; \
21// void delete_this() override { if(m_pfactory) m_pfactory->return_back(this); else delete this;}
22
23
24class CLASS_DECL_ACME manual_reset_happening :
25 public ::happening
26{
27public:
28
29
30 //__creatable(manual_reset_happening);
31
32
33 ::e_status m_estatus;
34 // DECLARE_REUSABLE(manual_reset_happening);
35
36
37 manual_reset_happening(char_pointer sz = nullptr, bool bInitiallyOwn = false);
38 ~manual_reset_happening() override;
39
40 //void reuse() { reset_happening(); }
41
42 void clear() { reset_happening(); }
43
44};
45
47
48class CLASS_DECL_ACME notify_lock :
49 virtual public ::particle
50{
51public:
52
53
54 manual_reset_happening * m_pmanualresethappening;
55
56
57 //::pointer < ::pointer_array< ::subparticle > > m_psynca;
58
59 ::preallocated_pointer_array_base < ::subparticle, 10 > m_synca;
60
61
62 notify_lock(manual_reset_happening * pmanualresethappening):
63 m_pmanualresethappening(pmanualresethappening)
64 {
65
66
67 }
68 void add(::subparticle *p)
69 {
70
71// if(!m_psynca)
72// {
73//
74// __raw_construct_new(m_psynca);
75//
76// }
77
78 m_synca.add_unique(p);
79
80// for (::i32 i = 0; i < m_iSyncCount; i++)
81// {
82//
83// auto & psync = m_synca[i];
84//
85// if(psync == p)
86// {
87//
88// return;
89//
90// }
91//
92// }
93//
94// for (::i32 i = 0; i < m_iSyncCount; i++)
95// {
96//
97// auto & psync = m_synca[i];
98//
99// if(!psync)
100// {
101// psync = p;
102//
103// return;
104//
105// }
106//
107// }
108// m_synca[m_iSyncCount] = p;
109//
110// m_iSyncCount++;
111//
112 }
113
114 void erase(::subparticle *p)
115 {
116// if(!m_psynca)
117// {
118//
119// return;
120// }
121
122// for (::i32 i = 0; i < m_iSyncCount; i++)
123// {
124//
125// auto & psync = m_synca[i];
126//if(psync == p)
127//{
128// psync.release();
129// break;
130//}
131//
132// }
133
134 }
135
136 ~notify_lock() override
137 {
138
139// if(m_psynca)
140 {
141
142 //for (auto & psync: *m_psynca)
143 for (auto & psync: m_synca)
144 {
145
146 //auto & psync = m_synca[i];
147 if(psync)
148 {
149 psync->end_notify_lock(this);
150
151 }
152
153 }
154
155 }
156
157 }
158
159};
160
Definition happening.h:37
Definition aaa_manual_reset_event.h:26
Definition subparticle.h:78