Refactor shared async state into a single structure per device#31
Open
Refactor shared async state into a single structure per device#31
Conversation
Refactor shared async state management into a single structure per device. * Add `async_state_t` structure in `PoKeysLibAsync.h` to encapsulate task queue, retries, and mutex. * Modify `sPoKeysDevice` in `PoKeysLibHal.h` to include a pointer to `async_state_t`. * Refactor functions in `PoKeysLibAsync.c` to use the new `async_state_t` structure for managing async transactions. - Update `transaction_alloc` and `transaction_find` to use `async_state_t`. - Modify `CreateRequestAsync`, `SendRequestAsync`, and `PK_ReceiveAndDispatch` to use `async_state_t`. - Update `PK_TimeoutAndRetryCheck` to use `async_state_t`. * Update `PoKeysLibCoreAsync.c` to initialize and manage `async_state_t` for each device during connection. - Initialize `async_state_t` in `PK_InitDeviceAsync`. - Clean up `async_state_t` in `PK_CleanDeviceAsync`. - Clone `async_state_t` in `PK_CloneDeviceStructureAsync`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/zarfld/pokeysHal?shareId=XXXX-XXXX-XXXX-XXXX).
… pointer to it. * Add `async_state_t` structure to `PoKeysLibHal.h` to encapsulate task queue and mutex. * Remove `async_state_t` structure from `PoKeysLibAsync.h`. * Include `pthread.h` in `PoKeysLibHal.h` for mutex support. * Modify `sPoKeysDevice` in `PoKeysLibHal.h` to include a pointer to `async_state_t`.
* Define `MAX_TRANSACTIONS` as 256 in `PoKeysLibHal.h` * Remove `MAX_TRANSACTIONS` definition from `PoKeysLibAsync.h`
* Add `#include PoKeysLibAsync.h` to include the new header file for async state management
* Fix the include statement to use quotes instead of angle brackets
… pointer to it * Add `async_state_t` structure to encapsulate task queue, retries, and mutex * Modify `sPoKeysDevice` to include a pointer to `async_state_t` * Move `transaction_status_t` and `pokeys_command_t` enums, `pokeys_response_parser_t` typedef, and `async_transaction_t` and `mailbox_entry_t` structures from `PoKeysLibAsync.h` to `PoKeysLibHal.h`
* Add `async_state_t* async_state` to `sPoKeysDevice` structure * Move `pokeys_response_parser_t` typedef to after `sPoKeysDevice` definition
…LibHal.h` * Add `async_transaction_t` structure to encapsulate task queue, retries, and mutex * Add `mailbox_entry_t` structure for managing async transactions * Modify `sPoKeysDevice` to include a pointer to `async_state_t`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor shared async state management into a single structure per device.
async_state_tstructure inPoKeysLibAsync.hto encapsulate task queue, retries, and mutex.sPoKeysDeviceinPoKeysLibHal.hto include a pointer toasync_state_t.PoKeysLibAsync.cto use the newasync_state_tstructure for managing async transactions.transaction_allocandtransaction_findto useasync_state_t.CreateRequestAsync,SendRequestAsync, andPK_ReceiveAndDispatchto useasync_state_t.PK_TimeoutAndRetryCheckto useasync_state_t.PoKeysLibCoreAsync.cto initialize and manageasync_state_tfor each device during connection.async_state_tinPK_InitDeviceAsync.async_state_tinPK_CleanDeviceAsync.async_state_tinPK_CloneDeviceStructureAsync.For more details, open the Copilot Workspace session.