CK_ARRAY_PUT(3)

πŸ’… CK_ARRAY_PUT(3) πŸ’…

okay bestie, welcome to the ck_array_put page β€” yes it's from the Concurrency Kit (that's libck, link it with -lck) and it's literally one of the most-used little functions in the whole array saga. sit down, grab a strawberry πŸ“, let's get into it.


🌸 NAME 🌸

ck_array_put β€” attempt immediate or deferred insertion of a pointer into array

like... you're sliding a pointer into an array and the array gets to decide when it actually lands there. iconic behavior tbh. ✨


πŸ“š LIBRARY πŸ“š

Concurrency Kit (that's libck, so you link with -lck) 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <ck_array.h>

bool
ck_array_put(ck_array_t *array, void *pointer);

two arguments, one bool, no drama. we love a minimal signature. πŸ‘‘


✨ DESCRIPTION ✨

So the way that ck_array_put(3) works is: it attempts to insert the value of pointer into the array that array points to. that's the whole vibe.

But heads up β€” this function may incur additional memory allocations if there isn't already enough memory allocated in the array to hold a new entry. so like, it might go shopping for more memory mid-operation. no cap, that's just how it is. πŸ™ˆ

Also, plot twist: the operation is free to apply the operation immediately if there's an opportunity for elimination with a pending (uncommitted) remove operation. so if a remove is just sitting there uncommitted and it could cancel out with your put β€” yeah, it might just go ahead and do that right then and there. it's giving ✨opportunistic✨. the array is the main character here, not you. πŸ’…


πŸ’– RETURN VALUES πŸ’–

  • true β€” slay, the put operation succeeded. πŸŽ‰
  • false β€” otherwise, and the reason is internal allocation failures. 😭

that's it, that's the return value situation.


πŸ‘€ SEE ALSO πŸ‘€

go read these next, they're all part of the same friend group:

and if you want even more info, additional information is available at http://concurrencykit.org/ 🌈


okay that's the whole page, you ate that. this one's dated October 18, 2013 and it lives under the name CK_ARRAY_PUT(3) β€” go forth and insert responsibly, bestie. mwah. πŸ’‹πŸ¦‹

πŸ“¦ where this page comes from