7#include "_impl_generic_map.h"
8#include "_impl_numeric_array.h"
9#include "_impl_payload.h"
12template<
typename ITERATOR_TYPE>
13inline auto & range < ITERATOR_TYPE >::first() { return ::get(this->begin()); }
14template<
typename ITERATOR_TYPE>
15inline auto & range < ITERATOR_TYPE >::first()
const {
return (CONST_ITEM &) ::get(this->begin()); }
18template<
typename ITERATOR_TYPE>
19inline const ::block block_range < ITERATOR_TYPE >::block()
const
22 return {(
const void *) (ITERATOR_TYPE) this->data(), this->size_in_bytes()};
27template<
typename ITERATOR_TYPE>
28inline ::block block_range < ITERATOR_TYPE >::block()
31 return {(
const void *) (ITERATOR_TYPE) this->data(), this->size_in_bytes()};
35#include "acme/handler/dispatch_array.h"
44 return {
this, e_dispatch_user_send };
60 return {
this, e_dispatch_user_post };
74 return {
this, e_dispatch_main_send };
88 return {
this, e_dispatch_main_post };
102 return {
this, e_dispatch_send };
131 return {
this, e_dispatch_post };
139#include "acme/exception/cancel.h"
144 template <
typename CONTEXT_TYPE >
145 void procedure_array_with_context<CONTEXT_TYPE>::run()
151 for (
auto & procedure : *
this)
159 catch (const ::cancel_exception<CONTEXT_TYPE> & cancelexception)
162 informationf(
"procedure_array : cancel_exception(%s) : %s", cancelexception.m_strContext.c_str(), cancelexception.m_strMessage.c_str());
173template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
174::collection::count base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::_allocate(::collection::count nNewSize,
bool bShrink,
bool bRaw,
bool bFollowingIsArray,
const TYPE * ptype)
238 ASSERT(nNewSize >= 0);
243 throw_exception(error_bad_argument);
247 ::collection::count countOld = get_count();
249 if(nNewSize == countOld)
259 if(this->m_begin !=
nullptr)
262 TYPED::destruct_count(this->m_begin, this->size());
270 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
271 m_countAllocation = 0;
272 this->m_begin =
nullptr;
284 this->m_countAllocationOffset = 0;
291 if (this->m_erange & e_range_array_clear_on_allocate)
294 memset((
void *) this->m_begin, 0, maximum(0, countOld) *
sizeof(TYPE));
302 this->m_end = this->m_begin;
305 else if(this->m_begin ==
nullptr)
308 if(nNewSize > UPTR_MAXIMUM /
sizeof(TYPE))
311 throw_exception(error_no_memory);
315 auto nAllocSize = maximum(nNewSize, m_countAddUp);
317#if MEMDLEAK || defined(__MCRTDBG)
319 if(::get_task() !=
nullptr)
322#if defined(__MCRTDBG)
324 if(::get_task()->m_strFile.has_character())
327 this->m_begin = MEMORY::allocate(nAllocSize, ::get_task()->m_strFile, ::get_task()->m_iLine);
333 this->m_begin = MEMORY::allocate(nAllocSize, __FILE__, __LINE__);
339 if (::get_task_object_debug().has_character())
342 this->m_begin = MEMORY::allocate(nAllocSize,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
348 this->m_begin = MEMORY::allocate(nAllocSize,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
358 this->m_begin = MEMORY::allocate(nAllocSize, __FILE__, __LINE__);
364 this->m_begin = MEMORY::allocate(nAllocSize, &nAllocSize);
368 if (this->m_erange & e_range_array_clear_on_allocate)
371 memset((
void *) this->m_begin, 0, nAllocSize *
sizeof(TYPE));
378 if (::is_null(ptype))
381 TYPED::construct_count(this->m_begin, nNewSize);
387 TYPED::copy_construct_count(this->m_begin, nNewSize, *ptype);
393 this->m_end = this->m_begin + nNewSize;
395 m_countAllocation = nAllocSize;
398 else if(nNewSize <= m_countAllocation)
401 defer_erase_allocation_offset();
406 if (nNewSize > countOld)
409 if (::is_null(ptype))
412 TYPED::construct_count(this->m_begin + countOld, nNewSize - countOld);
418 TYPED::copy_construct_count(this->m_begin + countOld, nNewSize - countOld, *ptype);
423 else if (countOld > nNewSize)
426 TYPED::destruct_count(this->m_begin + nNewSize, countOld - nNewSize);
428 if (this->m_erange & e_range_array_clear_on_allocate)
431 memset((
void *) (this->m_begin + nNewSize), 0, (countOld - nNewSize) *
sizeof(TYPE));
437 TYPED::construct_count(this->m_begin + nNewSize, countOld - nNewSize);
445 this->m_end = this->m_begin + nNewSize;
451 auto countAddUp = m_countAddUp;
456 countAddUp = this->size();
458 constrain(countAddUp, 4, 1024);
462 ::collection::count countNewAllocation;
464 if(nNewSize < m_countAllocation + countAddUp)
467 countNewAllocation = m_countAllocation + countAddUp;
473 countNewAllocation = nNewSize;
477 if(countNewAllocation > UPTR_MAXIMUM /
sizeof(TYPE))
480 throw_exception(error_no_memory);
484#if MEMDLEAK || defined(__MCRTDBG)
486 TYPE* pNewData =
nullptr;
488 if(::get_task() !=
nullptr)
491#if defined(__MCRTDBG)
493 if(::get_task()->m_strFile.has_character())
496 pNewData = MEMORY::allocate(countNewAllocation, ::get_task()->m_strFile,::get_task()->m_iLine);
502 pNewData = MEMORY::allocate(countNewAllocation, __FILE__, __LINE__);
508 if (::get_task_object_debug().has_character())
511 pNewData = MEMORY::allocate(countNewAllocation,
"thread://" + ::get_task_object_name() +
", " + ::get_task_object_debug() +
", " +
string(__FILE__), __LINE__);
517 pNewData = MEMORY::allocate(countNewAllocation,
"thread://" + ::get_task_object_name() +
", " +
string(__FILE__), __LINE__);
527 pNewData = MEMORY::allocate(countNewAllocation, __FILE__, __LINE__);
534 TYPE * pNewData = MEMORY::allocate(countNewAllocation, &countNewAllocation);
539 ::safe_memory_copy2(pNewData, (
size_t)countNewAllocation, this->m_begin, (
size_t) countOld);
541 if (this->m_erange & e_range_array_clear_on_allocate)
544 memset((
void *) (this->m_begin + countOld), 0, (countNewAllocation - countOld) *
sizeof(TYPE));
552 ASSERT(nNewSize > countOld);
554 if (nNewSize > countOld)
557 if (::is_null(ptype))
560 TYPED::construct_count(pNewData + countOld, nNewSize - countOld);
566 TYPED::copy_construct_count(pNewData + countOld, nNewSize - countOld, *ptype);
578 MEMORY::free(this->m_begin + this->m_countAllocationOffset);
588 this->m_begin = pNewData;
590 this->m_end = this->m_begin + nNewSize;
592 this->m_countAllocationOffset = 0;
594 m_countAllocation = countNewAllocation;
603template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
604void base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::array_base_ok()
const
612 ASSERT(this->m_countAllocation > 0);
618 ASSERT(!this->m_end);
620 ASSERT(this->m_countAllocation == 0);
628template <
class TYPE,
class ARG_TYPE >
629void list_base < TYPE, ARG_TYPE >::list_base_ok()
const
637 ASSERT(this->m_count > 0);
643 ASSERT(!this->m_end);
645 ASSERT(this->m_count == 0);
652template <
typename ITEM, enum_allocate t_eallocate >
653void node_set_base < ITEM, t_eallocate >::container_ok()
const
661 ASSERT(this->m_count > 0);
667 ASSERT(!this->m_end);
669 ASSERT(this->m_count == 0);
676template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
680 this->m_begin =
nullptr;
681 this->m_end =
nullptr;
682 this->m_erange = e_range_none;
685 m_countAllocation = 0;
686 m_countAllocationOffset = 0;
687 set_size(array.get_size());
690 TYPED::copy_count(this->m_begin, array.m_begin, this->size());
701template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
706 this->m_begin = array.m_begin;
707 this->m_end = array.m_end;
708 this->m_erange = array.m_erange;
709 this->m_countAddUp = array.m_countAddUp;
710 this->m_countAllocation = array.m_countAllocation;
711 this->m_countAllocationOffset = array.m_countAllocationOffset;
713 array.m_begin =
nullptr;
714 array.m_end =
nullptr;
715 array.m_erange = e_range_none;
716 array.m_countAllocation = 0;
717 array.m_countAllocation = 0;
718 array.m_countAllocationOffset = 0;
723template <
typename TYPE,
typename ARG_TYPE,
typename TYPED,
typename MEMORY, ::enum_type t_etypeContainer >
724template <
typename OTHER_RANGE >
725base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >::
726base_array(
const OTHER_RANGE &
range)
requires
727(container_range < OTHER_RANGE >
728 && !::std::is_base_of_v < base_array < TYPE, ARG_TYPE, TYPED, MEMORY, t_etypeContainer >, ::std::remove_cvref_t < OTHER_RANGE > >) :
732 for (
auto p =
range.begin();
range.is_iterator_ok(p); p++)
735 this->add((ARG_TYPE) *p);
Definition base_array.h:112
Definition dispatch_array.h:180
Definition _structures.h:51