Synchronized queue C++17
Complete the provided template so that the SBuffer class is an implementation of a synchronized queue. The queue should additionally manage a pool of objects of type ItemType. The constructor of the SBuffer class should create N objects of type ItemType. Only pointers to these objects can be returned by the implemented methods. It can also be assumed that all pointers passed as arguments have been previously returned by other methods of this same object.
Method specifications:
int enqueue(ItemType* item)— adds the object pointed to byitemto the end of the queue and returns1. Ifstop()has been called previously, does nothing and returns0.ItemType* dequeue()— removes the object from the beginning of the queue and returns a pointer to it. If the queue is empty, suspends thread execution until an accessible object appears or thestopmethod is called for the queue object.ItemType* allocItem()— returns any object of typeItemTypefrom the pool of currently unused objects. If all objects are currently busy, suspends thread execution until some object is freed orstopis called.void freeItem(ItemType* item)— marks the resource as freed by the thread. The passed object*itemshould return to the pool of unused objects.void stop()— from the momentstopis called on the queue object, theallocItemmethod always returnsnullptr, and thedequeuemethod returns objects until the queue is empty; after that, it also always returnsnullptr.
The queue must operate according to the specification during use by multiple threads. Solutions based on active waiting are not allowed.
Conditions:
1. **Prohibition of LLM-generation:** code will be strictly checked for plagiarism from publicly available AI models — it is strictly forbidden to refer to public LLMs for code writing.
2. **Evaluation:** your file will be uploaded to an automated testing system. To be accepted, it must pass all tests without errors.
Solution template
You should submit only the header file sbuffer.h. For thread synchronization, please use the capabilities of the C++17 standard library.
Applications 1
Client's review of cooperation with Roman Biniukov
Synchronized queue C++17The work was done quickly and efficiently.
Freelancer's review of cooperation with Vadym Hassieiev
Synchronized queue C++17Everything is great, thank you for the project
-
762 12 0 Good day. The task does not seem difficult. I reviewed the sbuffer.h file. I will implement according to the requirements. Feel free to contact me.
Current freelance projects in the category C & C++
Reverse engineering of console utilities for querying SSD controllers (Flash ID)1. Purpose of the work Extraction of the application programming interface (API) for interaction with SSD/NVMe controllers from the provided set of console utilities (Phison, Silicon Motion, Realtek, Maxiotek, Marvell, JMicron, etc.). The result should be working code in C/C++… C & C++, Desktop Apps ∙ 1 day 22 hours back ∙ 5 proposals |
Development of a Minecraft Java Seed Map / Seed Viewer for the websiteDevelopment of Minecraft Java Seed Map / Seed Viewer for the websiteProject Description A browser-based tool Minecraft Java Seed Map / Seed Viewer needs to be developed, which will work on our website and allow the user to enter a seed from Minecraft Java Edition and view an… C & C++, HTML & CSS ∙ 2 days 5 hours back ∙ 14 proposals |
Comparative analysis of the effectiveness of custom software (v2.2-field) and reference software (Meshtastic v2.x)
22 USD
Comparative analysis of the effectiveness of custom software (v2.2-field) and reference software (Meshtastic v2.x) on the identical hardware platform (ESP32 + SX1268, 2W) based on the criteria of range, throughput, link stability, and power consumption. Conduct tests with… C & C++, C# ∙ 6 days 12 hours back ∙ 2 proposals |
Consultation and audit of the current project on Odoo 19 Community EditionWe are looking for an Odoo Developer — a solo developer with experience in Odoo 19 Community Edition, including using Claude Code. We need a specialist who has successfully implemented projects in Odoo and practical experience in development using Claude Code. Important: we only… C & C++, Javascript and Typescript ∙ 9 days 13 hours back ∙ 8 proposals |
Software development for Arduino (RF modules 3–7.5 GHz, automatic frequency scanning)It is necessary to develop a system on Arduino for the automatic search of active analog video signals and the automatic tuning of the transmitter to the detected frequency.It is planned to use three separate transceiver modules: 3000–4200 MHz; 4900–6000 MHz; 6100–7500… C & C++, Embedded Systems & Microcontrollers ∙ 10 days 14 hours back ∙ 5 proposals |