Skip to content

will it be a bug for adding task to queue by other thread ? #4

Description

@Frandy

When add task into queue, it call execute as below,

template <std::invocable F> void execute(F &&f) {
        std::size_t i = count++ % _deques.size();

        _in_flight.fetch_add(1, std::memory_order_relaxed);
        _deques[i].tasks.emplace(std::forward<F>(f));
        _deques[i].sem.release();
    }

Since it use lock free deque, it supposes only one thread can push and pop at the front, and other threads only steal at the bottom. Is it right?
If so, it may have problem as adding task to thread i by other thread.
Would you please help explain why it is ok ?

Best wishes, thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions