MCPcopy Create free account
hub / github.com/acl-dev/acl / push

Method push

lib_acl_cpp/include/acl_cpp.cn/stdlib/tbox_array.hpp:83–116  ·  view source on GitHub ↗

* ������Ϣ���󣬱������������������Ƚ�����֪ͨ * @param t {T*} �ǿ���Ϣ���� * @param notify_first {bool} ���Ϊ true������֪ͨ������������Ƚ��� * ��֪ͨ��ע����ߵ����� * @return {bool} * @override */

Source from the content-addressed store, hash-verified

81 * @override
82 */
83 bool push(T* t, bool notify_first = false) {
84 if (! lock_.lock()) { abort(); }
85
86 if (off_next_ == capacity_) {
87 if (off_curr_ >= 10000) {
88#if 1
89 size_t n = 0;
90 for (size_t i = off_curr_; i < off_next_; i++) {
91 array_[n++] = array_[i];
92 }
93#else
94 memmove(array_, array_ + off_curr_,
95 (off_next_ - off_curr_) * sizeof(T*));
96#endif
97
98 off_next_ -= off_curr_;
99 off_curr_ = 0;
100 } else {
101 capacity_ += 10000;
102 array_ = (T**) realloc(array_, sizeof(T*) * capacity_);
103 }
104 }
105 array_[off_next_++] = t;
106
107 if (notify_first) {
108 if (! cond_.notify()) { abort(); }
109 if (! lock_.unlock()) { abort(); }
110 } else {
111 if (! lock_.unlock()) { abort(); }
112 if (! cond_.notify()) { abort(); }
113 }
114
115 return true;
116 }
117
118 /**
119 * ������Ϣ����

Callers

nothing calls this directly

Calls 4

reallocFunction · 0.85
lockMethod · 0.45
notifyMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected