MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / add_back

Method add_back

Kernel/include/list.h:248–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246 }
247
248 void add_back(const T& obj) {
249 acquireLock(&lock);
250
251 ListNode<T>* node;
252 if(cache.get_length() <= 0){
253 node = (ListNode<T>*)kmalloc(sizeof(ListNode<T>));
254 } else {
255 node = cache.remove_at(0);
256 }
257
258 assert(node);
259
260 node->obj = obj;
261 node->next = node->prev = nullptr;
262
263 if (!front) {
264 front = node;
265 }
266 else if (back){
267 back->next = node;
268 node->prev = back;
269 }
270 back = node;
271 num++;
272
273 releaseLock(&lock);
274 }
275
276 void add_front(const T& obj) {
277 acquireLock(&lock);

Callers 15

KernelProcessFunction · 0.45
kmainFunction · 0.45
WriteMethod · 0.45
RegisterDeviceFunction · 0.45
MapSharedMemoryFunction · 0.45
WaitTimeoutMethod · 0.45
ParseFunction · 0.45
InsertThreadIntoQueueFunction · 0.45
InsertNewThreadIntoQueueFunction · 0.45
scheduler.cppFile · 0.45
CreateProcessFunction · 0.45

Calls 3

kmallocFunction · 0.85
get_lengthMethod · 0.45
remove_atMethod · 0.45

Tested by

no test coverage detected