MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / init

Method init

Libraries/HttpClient/HttpClientScheduler.cpp:10–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8} // namespace
9
10SC::Result SC::HttpClientOperationScheduler::init(const HttpClientOperationSchedulerMemory& memory)
11{
12 if (initialized)
13 return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerAlreadyInitialized);
14 if (memory.operations.empty())
15 return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerOperationsMissing);
16 if (memory.readyOperations.sizeInElements() < memory.operations.sizeInElements())
17 return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerReadyStorageTooSmall);
18
19 // Validate every entry before installing any notifier or changing caller-owned ready state.
20 for (size_t idx = 0; idx < memory.operations.sizeInElements(); ++idx)
21 {
22 if (memory.operations[idx] == nullptr)
23 return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerOperationNull);
24 if (not memory.operations[idx]->isInitialized())
25 return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerOperationNotInitialized);
26 }
27
28 schedulerMemory = memory;
29 for (size_t idx = 0; idx < schedulerMemory.operations.sizeInElements(); ++idx)
30 {
31 schedulerMemory.readyOperations[idx] = 1;
32 schedulerMemory.operations[idx]->setNotifier(this);
33 }

Callers

nothing calls this directly

Calls 3

ResultClass · 0.50
isInitializedMethod · 0.45
broadcastMethod · 0.45

Tested by

no test coverage detected