Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0.0 rest refactor #69

Merged
merged 34 commits into from
May 30, 2022
Merged

V2.0.0 rest refactor #69

merged 34 commits into from
May 30, 2022

Conversation

lcsmuller
Copy link
Collaborator

What?

  1. Add a per-client thread for managing REST logic.
  2. Allow client to completely idle while not doing anything.

Why?

  1. Add a per-client thread for managing REST logic.
    1.1. Asynchronous requests logic would get entangled with Discord's Gateway loop, meaning performing asynchronous requests were only be possible while discord_run() is performing.
    1.2. Use the same implementation for both asynchronous and synchronous requests - rather than having repetitive code for handling each mode individually.
  2. Reduce the CPU cost of having to unnecessarily iterate the Concord's event-loop if it does not have any pending events.

How?

  1. By using the threadpool from threadpool.h to start a single REST manager thread.
  2. Wake-up the Concord's loop when the heartbeat (ping) interval has been reached.

Testing?

  1. Has been tested for memory leaks and OOB by leaving a test/racecond.c bot spamming.

Anything Else?

This PR will make implementing a solution for #35 far more trivial, considering there is no longer a dependency on the Discord's Gateway running.

lcsmuller and others added 30 commits May 20, 2022 15:43
…; rename idle_contexts to queues->recycling and add queues->completed
* wip(discord-rest): move bucket's pthread_cond_t to individual 'struct discord_context'

* fix(discord-rest_async.c): move io_poller_wakeup() back to discord_async_start_context()
to their appropriate 'discord-rest' module
* fix(discord-rest): race-conditions from cleanup ordering
discord-rest_request.c
* refactor(discord-rest_request): rename 'struct discord_async' -> 'struct
  discord_requestor', 'struct discord_request' -> 'struct
  discord_request', 'struct discord_context' -> 'struct
  discord_request'
* refactor(discord-rest_request): move every discord-rest.c logic that handles any
  of the discord-rest_request.c structures
…of 1sec enforced delay block, add wakeup to main thread's poll
…mutexes, no longer needed since its only run at the REST thread
@lcsmuller lcsmuller added the enhancement New feature or request label May 30, 2022
@lcsmuller lcsmuller merged commit c9e0b32 into v2.0.0 May 30, 2022
@lcsmuller lcsmuller deleted the v2.0.0-rest_refactor branch May 30, 2022 02:04
@lcsmuller lcsmuller mentioned this pull request May 30, 2022
@lcsmuller lcsmuller mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants