Skip to content

Refactor shared async state into a single structure per device#31

Open
zarfld wants to merge 8 commits intomainfrom
refactor-async-state
Open

Refactor shared async state into a single structure per device#31
zarfld wants to merge 8 commits intomainfrom
refactor-async-state

Conversation

@zarfld
Copy link
Copy Markdown
Owner

@zarfld zarfld commented May 15, 2025

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.

zarfld added 8 commits May 15, 2025 13:56
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant