MCPcopy Create free account
hub / github.com/XpuOS/xsched / EnqueueXQueueWaitAllCommand

Method EnqueueXQueueWaitAllCommand

preempt/src/xqueue/command_buffer.cpp:127–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127std::shared_ptr<XQueueWaitAllCommand> CommandBuffer::EnqueueXQueueWaitAllCommand()
128{
129 std::unique_lock<std::mutex> lock(mtx_);
130
131 if (xq_state_ == kQueueStateIdle) {
132 // If the XQueue is idle, syncing on this XQueue should return. Here, we should return
133 // a completed XCommand so that syncing on this XQueue will return immediately.
134 auto wait_all_cmd = std::dynamic_pointer_cast<XQueueWaitAllCommand>(last_enqueued_cmd_);
135 XASSERT(last_enqueued_cmd_->GetType() == kCommandTypeXQueueWaitAll &&
136 wait_all_cmd != nullptr,
137 "last_enqueued_cmd_ must be an XQueueWaitAllCommand if the XQueue is idle");
138 return wait_all_cmd;
139 }
140
141 if (last_enqueued_cmd_->GetType() == kCommandTypeXQueueWaitAll) {
142 auto wait_all_cmd = std::dynamic_pointer_cast<XQueueWaitAllCommand>(last_enqueued_cmd_);
143 XASSERT(wait_all_cmd != nullptr, "last_enqueued_cmd_ must be an XQueueWaitAllCommand");
144 return wait_all_cmd;
145 }
146
147 auto xcmd = std::make_shared<XQueueWaitAllCommand>();
148 xcmd->SetState(kCommandStatePending);
149 last_enqueued_cmd_ = xcmd;
150 cmds_.emplace_back(xcmd);
151
152 lock.unlock();
153 cv_.notify_all();
154 return xcmd;
155}

Callers 3

AsyncXQueueMethod · 0.80
SubmitWaitAllMethod · 0.80
WaitAllMethod · 0.80

Calls 3

SetStateMethod · 0.80
GetTypeMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected