return false;
}
+bool RGWCoroutinesStack::collect_next(RGWCoroutine *op, int *ret, RGWCoroutinesStack **collected_stack) /* returns true if found a stack to collect */
+{
+ rgw_spawned_stacks *s = (op ? &op->spawned : &spawned);
+ *ret = 0;
+ vector<RGWCoroutinesStack *> new_list;
+
+ if (collected_stack) {
+ *collected_stack = NULL;
+ }
+
+ for (vector<RGWCoroutinesStack *>::iterator iter = s->entries.begin(); iter != s->entries.end(); ++iter) {
+ RGWCoroutinesStack *stack = *iter;
+ if (!stack->is_done()) {
+ continue;
+ }
+ int r = stack->get_ret_status();
+ if (r < 0) {
+ *ret = r;
+ }
+
+ if (collected_stack) {
+ *collected_stack = stack;
+ } else {
+ stack->put();
+ }
+
+ s->entries.erase(iter);
+ return true;
+ }
+
+ return false;
+}
+
bool RGWCoroutinesStack::collect(int *ret) /* returns true if needs to be called again */
{
return collect(NULL, ret);
return stack->collect(this, ret);
}
+bool RGWCoroutine::collect_next(int *ret, RGWCoroutinesStack **collected_stack) /* returns true if found a stack to collect */
+{
+ return stack->collect_next(this, ret, collected_stack);
+}
+
int RGWCoroutine::wait(const utime_t& interval)
{
return stack->wait(interval);
{
bool done = false;
reenter(&drain_cr) {
- while (num_spawned() > num_cr_left) {
+ while (num_spawned() > (size_t)num_cr_left) {
yield wait_for_child();
int ret;
while (collect(&ret)) {
int call(RGWCoroutine *op); /* call at the same stack we're in */
void spawn(RGWCoroutine *op, bool wait); /* execute on a different stack */
bool collect(int *ret); /* returns true if needs to be called again */
+ bool collect_next(int *ret, RGWCoroutinesStack **collected_stack = NULL); /* returns true if found a stack to collect */
int wait(const utime_t& interval);
bool drain_children(int num_cr_left); /* returns true if needed to be called again */
void spawn(RGWCoroutine *source_op, RGWCoroutine *next_op, bool wait);
bool collect(RGWCoroutine *op, int *ret); /* returns true if needs to be called again */
+ bool collect_next(RGWCoroutine *op, int *ret, RGWCoroutinesStack **collected_stack); /* returns true if found a stack to collect */
public:
RGWCoroutinesStack(CephContext *_cct, RGWCoroutinesManager *_ops_mgr, RGWCoroutine *start = NULL);