• R/O
  • SSH
  • HTTPS

globalbase: Commit


Commit MetaInfo

Revisão5992 (tree)
Hora2020-03-25 18:24:10
Autorjoshua

Mensagem de Log

misc.

Mudança Sumário

Diff

--- modules/tinyState/trunk/proj/posix/m-makefile.in (revision 5991)
+++ modules/tinyState/trunk/proj/posix/m-makefile.in (revision 5992)
@@ -42,11 +42,11 @@
4242 @(eq,${MACHINE},Linux) set MACHINE_DEF Linux
4343
4444
45-@ set MACRO_INCLUDES "-I. -I${SRC}/arch/posix/h -I${SRC}/arch/posix/machine/${MACHINE_DIR}/h -I${SRC}/arch/posix/machine/${MACHINE_DIR}/${RELEASE}/h -I${SRC}/h -I/usr/local/ssl/include -I/usr/local/opt/openssl/include "
45+@ set MACRO_INCLUDES "-I. -I${SRC}/arch/posix/h -I${SRC}/arch/posix/machine/${MACHINE_DIR}/h -I${SRC}/arch/posix/machine/${MACHINE_DIR}/${RELEASE}/h -I${SRC}/h -I/usr/local/ssl/include -I/usr/local/opt/openssl/include -I/usr/local/opt/openssl@1.1/include "
4646 @ set INCLUDES "-I${src_dir} ${MACRO_INCLUDES} "
4747 # -Wuninitialized
4848 @ set CFLAGS "-g -c -Wreturn-type -D__EXTENSIONS__ -D${MACHINE_DEF} -D__ARCINFO__=\\"${ARCINFO}\\" "
49-@ set LIB " ${LIBS} -L/usr/local/opt/openssl/lib "
49+@ set LIB " ${LIBS} -L/usr/local/opt/openssl/lib -L/usr/local/opt/openssl@1.1/lib "
5050 @ set LIBCPP " -lstdc++ ${LIBS} "
5151 @ set CPPFLAGS " -frtti ${CFLAGS} "
5252
@@ -85,7 +85,7 @@
8585 #----------------------------------------------------
8686
8787 @ make suffix .t from suffix - .gtt
88- ${GTT} ${from} --dep=${to}.gtt.ap --base=${SRC} -inc . -inc /usr/include -inc /usr/local/include
88+ ${GTT} ${from} --dep=${to}.gtt.ap --base=${SRC} -inc . -inc /usr/include -inc /usr/local/include -inc /usr/local/opt/openssl@1.1/include
8989 touch ${to}.t
9090
9191 @ make suffix .t from suffix - .c
--- modules/tinyState/trunk/src/classes/ts/c++/sObject.cpp (revision 5991)
+++ modules/tinyState/trunk/src/classes/ts/c++/sObject.cpp (revision 5992)
@@ -45,8 +45,19 @@
4545
4646 INTEGER64
4747 sObject::total_mem_max = 0;
48+pthread_mutex_t
49+sObject::refMutex;
50+uint8_t
51+sObject::refMutex_init;
52+uint8_t
53+sObject::refMutex_debug;
54+pthread_t
55+sObject::refMutex_thread;
56+int
57+sObject::refMutex_count;
4858
4959
60+
5061 static int
5162 get_cp_hash(const char * file,int line)
5263 {
@@ -160,6 +171,7 @@
160171 throw(std::bad_alloc)
161172 #endif
162173 {
174+ sObject::refLock();
163175 MEM_HEADER * mem = (MEM_HEADER*)malloc(cbSize+sizeof(MEM_HEADER));
164176 mem->size = cbSize;
165177 mem->cp = get_cp(__file,__line,ref_subline,cp_hash_mem);
@@ -169,6 +181,8 @@
169181 mem ++;
170182 memset(mem,0,cbSize);
171183 //printf("new %p %lu %s %i\n",mem,cbSize,__file,__line);
184+
185+ sObject::refUnlock();
172186 return (void*)mem;
173187 }
174188
@@ -183,6 +197,8 @@
183197
184198 MEM_HEADER * mem;
185199 size_t cbSize;
200+
201+ refLock();
186202 mem = (MEM_HEADER*)pv;
187203 mem --;
188204 cp_set_size(mem->cp,-mem->size);
@@ -191,6 +207,7 @@
191207 cbSize = mem->size;
192208 memset(pv,0xaa,cbSize);
193209 free(mem);
210+ refUnlock();
194211 }
195212
196213 void
@@ -197,11 +214,14 @@
197214 sObject::refine_sobj(void * mp,const char * file,int line)
198215 {
199216 MEM_HEADER * mem;
217+
218+ refLock();
200219 mem = (MEM_HEADER*)mp;
201220 mem--;
202221 cp_set_size(mem->cp,-mem->size);
203222 mem->cp = get_cp(file,line,0,cp_hash_mem);
204223 cp_set_size(mem->cp,mem->size);
224+ refUnlock();
205225 }
206226
207227 void
@@ -215,9 +235,14 @@
215235 sObject::get_sobj_file()
216236 {
217237 MEM_HEADER * mem;
238+const char * ret;
239+
240+ refLock();
218241 mem = (MEM_HEADER*)this;
219242 mem--;
220- return mem->cp->filename;
243+ ret = mem->cp->filename;
244+ refUnlock();
245+ return ret;
221246 }
222247
223248 int
@@ -224,9 +249,13 @@
224249 sObject::get_sobj_line()
225250 {
226251 MEM_HEADER * mem;
252+int ret;
253+ refLock();
227254 mem = (MEM_HEADER*)this;
228255 mem--;
229- return mem->cp->line;
256+ ret = mem->cp->line;
257+ refUnlock();
258+ return ret;
230259 }
231260
232261 void *
@@ -237,6 +266,8 @@
237266 throw(std::bad_alloc)
238267 #endif
239268 {
269+
270+ sObject::refLock();
240271 // ::printf("new[] %lu %s %i\n",cbSize,__file,__line);
241272 MEM_HEADER * mem = (MEM_HEADER*)malloc(cbSize+sizeof(MEM_HEADER));
242273 mem->size = cbSize;
@@ -246,6 +277,7 @@
246277 //insert_active_list(mem);
247278 mem ++;
248279 memset(mem,0,cbSize);
280+ sObject::refUnlock();
249281 return mem;
250282 }
251283
@@ -257,6 +289,7 @@
257289 throw()
258290 #endif
259291 {
292+ sObject::refLock();
260293 //printf("DELETE [] %p\n",pv);
261294 MEM_HEADER * mem = (MEM_HEADER*)pv;
262295 mem --;
@@ -265,6 +298,7 @@
265298 //delete_active_list(mem);
266299 memset(pv,0xaa,mem->size);
267300 free(mem);
301+ sObject::refUnlock();
268302 }
269303
270304 static CODE_POS * cp_hash_fd[CP_HASH_SIZE];
@@ -469,3 +503,89 @@
469503 descriptor_top = cp;
470504 unlock_open();
471505 }
506+
507+
508+void
509+sObject::refLock() {
510+int er;
511+pthread_t tid;
512+
513+ if ( refMutex_init == 0 ) {
514+ pthread_mutexattr_t attr;
515+ pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
516+ if ( (er = pthread_mutex_init(&refMutex,&attr)) ) {
517+ refMutex_init = 2;
518+ if ( (er = pthread_mutex_init(&refMutex,0)) ) {
519+ fprintf(stderr,"%s\n",strerror(er));
520+ stdObject::panic("refLock-0");
521+ }
522+ }
523+ else
524+ refMutex_init = 1;
525+ }
526+ if ( refMutex_init == 1 ) {
527+ if ( (er=pthread_mutex_lock(&refMutex)) ) {
528+ fprintf(stderr,"%s\n",strerror(er));
529+ stdObject::panic("refLock-0");
530+ }
531+ }
532+ else {
533+ tid = pthread_self();
534+if ( refMutex_debug )
535+::printf("refLock-IN %p %p %i\n",tid,refMutex_thread,refMutex_count);
536+ if ( refMutex_thread == tid ) {
537+ refMutex_count ++;
538+if ( refMutex_debug )
539+::printf("refLock-0 %p %i\n",refMutex_thread,refMutex_count);
540+ return;
541+ }
542+ if ( (er=pthread_mutex_lock(&refMutex)) ) {
543+ fprintf(stderr,"%s\n",strerror(er));
544+ stdObject::panic("refLock-0");
545+ }
546+ if ( refMutex_count ) {
547+ if ( refMutex_thread != tid )
548+ stdObject::panic("refLock-1");
549+ }
550+ else {
551+ if ( refMutex_thread != 0 )
552+ stdObject::panic("refLock-2");
553+ }
554+ refMutex_thread = tid;
555+ refMutex_count ++;
556+if ( refMutex_debug )
557+::printf("refLock-1 %p %i\n",refMutex_thread,refMutex_count);
558+ }
559+}
560+
561+
562+void
563+sObject::refUnlock() {
564+int er;
565+ if ( refMutex_init == 1 ) {
566+ if ( (er=pthread_mutex_unlock(&refMutex)) ) {
567+ fprintf(stderr,"%s\n",strerror(er));
568+ stdObject::panic("refUnlock-3");
569+ }
570+ }
571+ else {
572+if ( refMutex_debug )
573+::printf("refUnlock %p %i\n",refMutex_thread,refMutex_count);
574+ if ( refMutex_count == 0 )
575+ stdObject::panic("refUnlock-1!!");
576+ pthread_t tid;
577+ tid = pthread_self();
578+ if ( refMutex_thread != tid )
579+ stdObject::panic("refUnlock-2!!");
580+ refMutex_count --;
581+ if ( refMutex_count == 0 ) {
582+ refMutex_thread = 0;
583+if ( refMutex_debug )
584+::printf("refUnlock-1 %p %i\n",refMutex_thread,refMutex_count);
585+ if ( (er=pthread_mutex_unlock(&refMutex)) ) {
586+ fprintf(stderr,"%s\n",strerror(er));
587+ stdObject::panic("refUnlock-3");
588+ }
589+ }
590+ }
591+}
--- modules/tinyState/trunk/src/classes/ts/c++/stdObject.cpp (revision 5991)
+++ modules/tinyState/trunk/src/classes/ts/c++/stdObject.cpp (revision 5992)
@@ -13,17 +13,6 @@
1313 int
1414 stdObject::load_mem_amount;
1515
16-pthread_mutex_t
17-stdObject::refMutex;
18-uint8_t
19-stdObject::refMutex_init;
20-uint8_t
21-stdObject::refMutex_debug;
22-pthread_t
23-stdObject::refMutex_thread;
24-int
25-stdObject::refMutex_count;
26-
2716 stdObject::stdObject()
2817 {
2918 refLock();
@@ -41,93 +30,8 @@
4130 }
4231
4332
44-void
45-stdObject::refLock() {
46-int er;
47-pthread_t tid;
4833
49- if ( refMutex_init == 0 ) {
50- pthread_mutexattr_t attr;
51- pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
52- if ( (er = pthread_mutex_init(&refMutex,&attr)) ) {
53- refMutex_init = 2;
54- if ( (er = pthread_mutex_init(&refMutex,0)) ) {
55- fprintf(stderr,"%s\n",strerror(er));
56- stdObject::panic("refLock-0");
57- }
58- }
59- else
60- refMutex_init = 1;
61- }
62- if ( refMutex_init == 1 ) {
63- if ( (er=pthread_mutex_lock(&refMutex)) ) {
64- fprintf(stderr,"%s\n",strerror(er));
65- stdObject::panic("refLock-0");
66- }
67- }
68- else {
69- tid = pthread_self();
70-if ( refMutex_debug )
71-::printf("refLock-IN %p %p %i\n",tid,refMutex_thread,refMutex_count);
72- if ( refMutex_thread == tid ) {
73- refMutex_count ++;
74-if ( refMutex_debug )
75-::printf("refLock-0 %p %i\n",refMutex_thread,refMutex_count);
76- return;
77- }
78- if ( (er=pthread_mutex_lock(&refMutex)) ) {
79- fprintf(stderr,"%s\n",strerror(er));
80- stdObject::panic("refLock-0");
81- }
82- if ( refMutex_count ) {
83- if ( refMutex_thread != tid )
84- stdObject::panic("refLock-1");
85- }
86- else {
87- if ( refMutex_thread != 0 )
88- stdObject::panic("refLock-2");
89- }
90- refMutex_thread = tid;
91- refMutex_count ++;
92-if ( refMutex_debug )
93-::printf("refLock-1 %p %i\n",refMutex_thread,refMutex_count);
94- }
95-}
9634
97-
98-void
99-stdObject::refUnlock() {
100-int er;
101- if ( refMutex_init == 1 ) {
102- if ( (er=pthread_mutex_unlock(&refMutex)) ) {
103- fprintf(stderr,"%s\n",strerror(er));
104- stdObject::panic("refUnlock-3");
105- }
106- }
107- else {
108-if ( refMutex_debug )
109-::printf("refUnlock %p %i\n",refMutex_thread,refMutex_count);
110- if ( refMutex_count == 0 )
111- stdObject::panic("refUnlock-1!!");
112- pthread_t tid;
113- tid = pthread_self();
114- if ( refMutex_thread != tid )
115- stdObject::panic("refUnlock-2!!");
116- refMutex_count --;
117- if ( refMutex_count == 0 ) {
118- refMutex_thread = 0;
119-if ( refMutex_debug )
120-::printf("refUnlock-1 %p %i\n",refMutex_thread,refMutex_count);
121- if ( (er=pthread_mutex_unlock(&refMutex)) ) {
122- fprintf(stderr,"%s\n",strerror(er));
123- stdObject::panic("refUnlock-3");
124- }
125- }
126- }
127-}
128-
129-
130-
13135 void
13236 stdObject::addref()
13337 {
--- modules/tinyState/trunk/src/classes/ts/c++/tsThread.cpp (revision 5991)
+++ modules/tinyState/trunk/src/classes/ts/c++/tsThread.cpp (revision 5992)
@@ -556,6 +556,8 @@
556556 return;
557557 if ( max_thread_nos > 0 ) {
558558 if ( current_thread_nos >= max_thread_nos ) {
559+if ( run_thread_nos >= current_thread_nos )
560+::printf("--------------------------------------------------- LAUNCH-FULL %i %i\n",run_thread_nos,current_thread_nos);
559561 cond_signal();
560562 return;
561563 }
--- modules/tinyState/trunk/src/h/ts/c++/sObject.h (revision 5991)
+++ modules/tinyState/trunk/src/h/ts/c++/sObject.h (revision 5992)
@@ -27,6 +27,11 @@
2727 #else
2828 throw();
2929 #endif
30+ static void refLock();
31+ static void refUnlock();
32+ static uint8_t refMutex_debug;
33+
34+
3035 static void panic(const char*);
3136
3237 static INTEGER64 total_mem_max;
@@ -58,6 +63,13 @@
5863 static void refine_fd(int s,const char * filename,int line);
5964
6065 static void fd_stdio();
66+
67+ protected:
68+ static pthread_mutex_t refMutex;
69+ static uint8_t refMutex_init;
70+ static pthread_t refMutex_thread;
71+ static int refMutex_count;
72+
6173 };
6274
6375 #define soOPEN(x,y,z) sObject::__open(__FILE__,__LINE__,x,y,z)
@@ -83,7 +95,7 @@
8395
8496 #define COMMA ,
8597 #define NEW new (__FILE__,__LINE__)
86-#define thNEW(__type,__arg) (stdObject::refLock(),sPtr<__type>(NEW __type __arg,1))
98+#define thNEW(__type,__arg) (sObject::refLock(),sPtr<__type>(NEW __type __arg,1))
8799
88100
89101
--- modules/tinyState/trunk/src/h/ts/c++/stdArrayQueue.h (revision 5991)
+++ modules/tinyState/trunk/src/h/ts/c++/stdArrayQueue.h (revision 5992)
@@ -4,6 +4,8 @@
44 #ifndef ___stdArrayQueue_cpp_H___
55 #define ___stdArrayQueue_cpp_H___
66
7+#define AQ_DEBUG_MODE
8+
79 #include <pthread.h>
810
911 #define AQE_OK 0
@@ -19,6 +21,9 @@
1921 #define sAQ_DETACH 1
2022 #define sAQ_ATTACH 2
2123
24+
25+#define AQ_LINE(x) (x).line(__FILE__,__LINE__);
26+
2227 template <class __TYPE>
2328 class sAQindex;
2429
@@ -35,13 +40,16 @@
3540 initial(inp->length());
3641
3742 int i;
43+ unsigned int ptr;
3844 lock();
3945 tail = inp->tail;
4046 head = inp->head;
4147 for ( i = 0 ; i < a->length() ; i ++ ) {
4248 a->ary[i] = inp->a->ary[i];
43- ix->ary[i] = inp->ix->ary[i];
49+ ix->ary[i] = AQ_EMPTY;
4450 }
51+ for ( ptr = tail ; ptr != head ; ptr ++ )
52+ ix->ary[ptr%ix->length()] = 0;
4553 unlock();
4654 }
4755 ~stdArrayQueue() {
@@ -66,7 +74,28 @@
6674 int length() {
6775 return a->length();
6876 }
77+ int truncate(sAQindex<__TYPE> from,sAQindex<__TYPE> to) {
78+ sAQindex<__TYPE> ptr;
79+ AQ_LINE(ptr);
80+ if ( from > to )
81+ return -1;
82+ ptr.set(this);
83+ for ( ; ; ) {
84+ ptr.tail();
85+ if ( ptr == from )
86+ break;
87+ ptr.del();
88+ }
89+ for ( ; ; ) {
90+ ptr.head();
91+ if ( ptr == to )
92+ break;
93+ ptr.pop();
94+ }
95+ return 0;
96+ }
6997
98+
7099 protected:
71100 int i_count() {
72101 return head - tail;
@@ -78,6 +107,10 @@
78107 len = regular_length(len);
79108 n = thNEW(stdArray<__TYPE COMMA false>, (len));
80109 nix = thNEW(stdArray<int COMMA false>, (len));
110+#ifdef AQ_DEBUG_MODE
111+ sPtr<stdArray<sAQindex<__TYPE>*,false > > dl;
112+ dl = thNEW(stdArray<sAQindex<__TYPE> * COMMA false>,(len));
113+#endif
81114 if ( count() < len )
82115 ncount = count();
83116 else {
@@ -88,10 +121,17 @@
88121 for ( i = tail ; i != head ; ) {
89122 n->ary[i%n->length()] = a->ary[i%a->length()];
90123 nix->ary[i%n->length()] = ix->ary[i%a->length()];
124+#ifdef AQ_DEBUG_MODE
125+ dl->ary[i%n->length()]
126+ = debug_list->ary[i%a->length()];
127+#endif
91128 i ++;
92129 }
93130 a = n;
94131 ix = nix;
132+#ifdef AQ_DEBUG_MODE
133+ debug_list = dl;
134+#endif
95135 }
96136 int regular_length(int len) {
97137 int i;
@@ -111,69 +151,96 @@
111151
112152 pthread_mutex_init(&mu,0);
113153 pthread_cond_init(&cond,0);
154+
155+#ifdef AQ_DEBUG_MODE
156+ debug_list = thNEW(stdArray<sAQindex<__TYPE>* COMMA false>,(len));
157+#endif
114158 }
115159 __TYPE * get(unsigned int pos) {
116160 return &a->ary[pos%a->length()];
117161 }
118162
119-
120163 unsigned int ins() {
121164 int ret;
122- if ( count() == a->length() )
165+ if ( i_count() == a->length() )
123166 del();
124167 ret = head ++;
125- ix->ary[ret] = AQ_INS;
168+ ix->ary[ret%ix->length()] = AQ_INS;
126169 return ret;
127170 }
128171 int del() {
129- if ( count() == 0 )
172+ if ( i_count() == 0 )
130173 return AQE_ERROR;
131- for ( ; ix->ary[tail] ; ) {
174+ for ( ; ix->ary[tail%a->length()] ; ) {
132175 wait_count ++;
133176 pthread_cond_wait(&cond,&mu);
134- lock();
135177 }
136178 tail ++;
137179 return 0;
138180 }
139- int attach(unsigned int p) {
181+ int pop() {
182+ int ret;
183+ if ( i_count() == 0 )
184+ return AQE_ERROR;
185+ ret = head - 1;
186+ for ( ; ix->ary[ret%a->length()] ; ) {
187+ wait_count ++;
188+ pthread_cond_wait(&cond,&mu);
189+ }
190+ head = ret;
191+ return 0;
192+ }
193+ int idx(unsigned int p) {
194+ return ix->ary[p%ix->length()];
195+ }
196+ int attach(unsigned int p,sAQindex<__TYPE> * org) {
140197 for ( ; ; ) {
141198 if ( head < tail ) {
142199 if ( head <= p && p < tail )
143200 return AQE_ERROR;
144201 }
145- else if ( !(head <= p && p < tail) )
202+ else if ( head <= p || p < tail )
146203 return AQE_ERROR;
147- if ( ix->ary[p] >= 0 )
204+ if ( ix->ary[p%ix->length()] >= 0 )
148205 break;
149206 wait_count ++;
150207 pthread_cond_wait(&cond,&mu);
151- lock();
152208 }
153- ix->ary[p] ++;
209+ ix->ary[p%ix->length()] ++;
210+#ifdef AQ_DEBUG_MODE
211+ org->debug_next = debug_list->ary[p%ix->length()];
212+ debug_list->ary[p%ix->length()] = org;
213+#endif
154214 return 0;
155215 }
156- int detach(unsigned int p) {
157- if ( p < 0 )
158- return 0;
216+ int detach(unsigned int p,sAQindex<__TYPE> * org) {
159217 if ( head < tail ) {
160218 if ( head <= p && p < tail )
161219 return AQE_ERROR;
162220 }
163- else if ( !(head <= p && p < tail) )
221+ else if ( head <= p || p < tail )
164222 return AQE_ERROR;
165- if ( ix->ary[p] == 0 )
223+ if ( ix->ary[p%ix->length()] == 0 )
166224 return AQE_ERROR;
167- if ( ix->ary[p] == AQ_INS ) {
168- ix->ary[p] = 0;
225+ if ( ix->ary[p%ix->length()] == AQ_INS ) {
226+ ix->ary[p%ix->length()] = 0;
169227 }
170228 else {
171- ix->ary[p] --;
229+ ix->ary[p%ix->length()] --;
172230 }
173- if ( ix->ary[p] == 0 ) {
231+ if ( ix->ary[p%ix->length()] == 0 ) {
174232 for ( ; wait_count > 0 ; wait_count -- )
175233 pthread_cond_signal(&cond);
176234 }
235+#ifdef AQ_DEBUG_MODE
236+ sAQindex<__TYPE> ** pp;
237+ for ( pp = &debug_list->ary[p%a->length()] ;
238+ *pp && *pp != org ;
239+ pp = &(*pp)->debug_next);
240+ if ( *pp )
241+ *pp = org->debug_next;
242+
243+#endif
177244 return 0;
178245 }
179246
@@ -186,6 +253,10 @@
186253
187254 sPtr<stdArray<__TYPE,false> > a;
188255 sPtr<stdArray<int,false> > ix;
256+#ifdef AQ_DEBUG_MODE
257+ sPtr<stdArray<sAQindex<__TYPE>*, false> > debug_list;
258+#endif
259+
189260 unsigned int head;
190261 unsigned int tail;
191262
@@ -198,6 +269,8 @@
198269 template <class __TYPE>
199270 class sAQindex : public sObject {
200271 public:
272+ friend class stdArrayQueue<__TYPE>;
273+
201274 sAQindex() {
202275 pos = 0;
203276 ptr = 0;
@@ -211,6 +284,10 @@
211284 a = inp.a;
212285 pos = 0;
213286 ptr = 0;
287+ if ( a.is_clear() ) {
288+ pos = inp.pos;
289+ return;
290+ }
214291 a->lock();
215292 pos = inp.pos;
216293 attach();
@@ -217,6 +294,8 @@
217294 a->unlock();
218295 }
219296 ~sAQindex() {
297+ if ( a.is_clear() )
298+ return;
220299 a->lock();
221300 detach();
222301 a->unlock();
@@ -229,24 +308,47 @@
229308 return sAQ_ATTACH;
230309 }
231310 void set(sPtr<stdArrayQueue<__TYPE> > aa) {
311+ if ( a ) {
312+ a->lock();
313+ detach();
314+ a->unlock();
315+ }
232316 a = aa;
317+ if ( a ) {
318+ a->lock();
319+ attach();
320+ a->unlock();
321+ }
233322 }
234323
324+ void line(const char* __file,int __line) {
325+#ifdef AQ_DEBUG_MODE
326+ _line = __line;
327+ _file = __file;
328+#endif
329+ }
330+
235331 __TYPE * get_ptr() {
236332 return ptr;
237333 }
238334 void clear() {
335+ if ( a.is_clear() )
336+ return;
239337 a->lock();
240338 detach();
241339 a->unlock();
242340 }
243341 int is_tail() {
244- if ( pos == a->tail )
342+ if ( a && (pos == a->tail) )
245343 return 1;
246344 return 0;
247345 }
248346 int is_head() {
249- if ( pos == a->head )
347+ if ( a.is_clear() )
348+ return 0;
349+ if ( a->tail == a->head )
350+ return 0;
351+ if ( pos == a->head-1 )
250352 return 1;
251353 return 0;
252354 }
@@ -253,7 +355,6 @@
253355 int number() {
254356 return pos - a->tail;
255357 }
256-
257358 int tail() {
258359 int ret;
259360 a->lock();
@@ -275,7 +376,7 @@
275376 return ret;
276377 }
277378 int i_head() {
278- if ( a->count() == 0 )
379+ if ( a->i_count() == 0 )
279380 return AQE_ERROR;
280381 detach();
281382 pos = a->head-1;
@@ -295,7 +396,8 @@
295396 if ( ret < 0 )
296397 return AQE_ERROR;
297398 detach();
298- pos = a->head;
399+ pos = ret;
400+ ptr = a->get(pos);
299401 return 0;
300402 }
301403 int del() {
@@ -306,13 +408,30 @@
306408 return ret;
307409 }
308410 int i_del() {
309- int ret;
310411 if ( pos == a->tail )
311412 detach();
312413 return a->del();
313414 }
415+ int pop() {
416+ int ret;
417+ a->lock();
418+ ret = i_pop();
419+ a->unlock();
420+ return ret;
421+ }
422+ int i_pop() {
423+ if ( pos == (int)(a->head - 1) )
424+ detach();
425+ return a->pop();
426+ }
314427 sAQindex& operator=(sAQindex inp) {
315- a = inp.a;
428+ if ( a ) {
429+ a->lock();
430+ detach();
431+ a->unlock();
432+ }
433+ if ( inp.a )
434+ a = inp.a;
316435 a->lock();
317436 pos = inp.pos;
318437 attach();
@@ -405,6 +524,13 @@
405524 return *ptr;
406525 }
407526 protected:
527+
528+#ifdef AQ_DEBUG_MODE
529+ sAQindex<__TYPE> * debug_next;
530+ const char * _file;
531+ int _line;
532+#endif
533+
408534 sPtr<stdArrayQueue<__TYPE> > a;
409535 int pos;
410536 __TYPE * ptr;
@@ -413,7 +539,7 @@
413539 int ret;
414540 if ( ptr )
415541 return 0;
416- ret = a->attach(pos);
542+ ret = a->attach(pos,this);
417543 if ( ret == 0 )
418544 ptr = a->get(pos);
419545 else ptr = 0;
@@ -422,7 +548,7 @@
422548 int detach() {
423549 if ( ptr == 0 )
424550 return 0;
425- a->detach(pos);
551+ a->detach(pos,this);
426552 ptr = 0;
427553 return 0;
428554 }
--- modules/tinyState/trunk/src/h/ts/c++/stdObject.h (revision 5991)
+++ modules/tinyState/trunk/src/h/ts/c++/stdObject.h (revision 5992)
@@ -29,11 +29,7 @@
2929 static const char * trace_all;
3030 static int load_mem_amount;
3131
32- static void refLock();
33- static void refUnlock();
3432
35-
36- static uint8_t refMutex_debug;
3733 protected:
3834 virtual void refNotice() {}
3935 virtual void refNotice1() {}
@@ -40,11 +36,6 @@
4036 virtual void refCount(int ref,int inc_flag) {}
4137
4238 private:
43- static pthread_mutex_t refMutex;
44- static uint8_t refMutex_init;
45- static pthread_t refMutex_thread;
46- static int refMutex_count;
47-
4839 void insert_zombie_list();
4940 void delete_zombie_list();
5041
Show on old repository browser