Я создал следующий простой интерфейс для доступа к стороннему API из оболочки:
Код: Выделить всё
#include
#include
#include "thirdparty_api.hpp"
int main(int argc, char *argv[])
{
if (argc < 2) return EXIT_FAILURE;
std::cout tpapi_run b
another result
Код: Выделить всё
process_1: tpapi_run a > process_1 receives result corresponding to a
process_2: tpapi_run b > process_2 is waiting
process_3: tpapi_run c > process_3 is waiting
process_1: tpapi_run b > process_1 receives result corresponding to b
...
process_1: tpapi_release > process_2 receives result corresponding to b
process_2: tpapi_run a > process_2 receives result corresponding to a
...
process_2: tpapi_release > process 3 receives result corresponding to c
Набросок алгоритма может быть следующим:
Код: Выделить всё
int main(int argc, char *argv[])
{
if (argc < 2) return EXIT_FAILURE;
// Create file named with pid in queue folder;
// List all files in queue folder and sort by date/time;
// while (own pid is not the oldest) {
// sleep(1);
// List all files in queue folder and sort by date/time;
// }
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79317930/best-way-to-implement-an-access-queue-to-a-shared-resource[/url]