forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Asynchronous Inbox + asynchronous house saving

Open gunzino opened this issue 2 years ago • 2 comments

  • [x] I have followed [proper The Forgotten Server code styling][code].
  • [x] I have read and understood the [contribution guidelines][cont] before making this PR.
  • [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.

Changes Proposed

I'm happy to share a contribution to the TFS which consists of async, zero-blocking Inbox implementation to prevent abusing the current sync system with large Inboxes and causing lags due to database IO like mentioned here #1431. The similar implementation is rotating between server owners but does not include complete zero-blocking IO for both saving and loading and parcel/item delivery to Inbox when player is offline. The implementation can be further used for more components like depots, store inbox etc. but those are currently either limited or controlled by server. The basic concept was created by kondra ([email protected]) few years ago but the code is already widespread across server owners which some of them resell for real money.

The implementation highlights:

  • The database IO and some of the serialization is done in separate thread (secondary Dispatcher g_dispatcherInbox) with dedicated database connection
  • Data structures protected by mutex
  • Async zero-blocking delivery of parcels and items from market/houses

Items delivery to inbox currently done for:

  • Houses
  • Parcels
  • Market

EDIT (21th November): Added asynchronous houses saving

I would be really happy for your hints/recommendations regarding so this contribution can be pushed to the master branch.

gunzino avatar Nov 08 '23 14:11 gunzino

@ramon-bernardo I've added async house saving today as well which uses similar approach. Can you review?

gunzino avatar Nov 21 '23 11:11 gunzino

This looks like a very promising PR, what is the status of this?

Codinablack avatar Apr 16 '24 04:04 Codinablack