Skip to content

Commit

Permalink
Adding isCooperative method - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Apr 4, 2024
1 parent 3a38f0c commit 5002e64
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Os/Posix/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,12 @@ namespace Os {
}
return status;
}

bool PosixTask::isCooperative() {
return false;
}

TaskHandle* PosixTask::getHandle() {
return &this->m_handle;
}
}
6 changes: 6 additions & 0 deletions Os/Posix/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ namespace Os {
//!
void resume() override;

//! \brief determine that the task is not cooperative
//!
//! Posix tasks are not cooperative and as-such the function returns false
//! \return false
bool isCooperative() override;

//! \brief return the underlying task handle (implementation specific)
//! \return internal task handle representation
TaskHandle* getHandle() override;
Expand Down
5 changes: 5 additions & 0 deletions Os/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ void Task::resume() {
this->m_delegate.resume();
}

bool Task::isCooperative() {
FW_ASSERT(&this->m_delegate == reinterpret_cast<TaskInterface*>(&this->m_handle_storage[0]));
return this->m_delegate.isCooperative();
}

TaskHandle* Task::getHandle() {
FW_ASSERT(&this->m_delegate == reinterpret_cast<TaskInterface*>(&this->m_handle_storage[0]));
return this->m_delegate.getHandle();
Expand Down
6 changes: 5 additions & 1 deletion Os/Task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Os {
//!
//! This function indicates if the task requires cooperative support.
//! \return true when the task expects cooperation, false otherwise
virtual bool isCooperative();
virtual bool isCooperative() = 0;

//! \brief return the underlying task handle (implementation specific)
//! \return internal task handle representation
Expand Down Expand Up @@ -284,6 +284,10 @@ namespace Os {
//!
void resume() override;

//! \brief determine if the task is cooperative multitasking (implementation specific)
//! \return true if cooperative, false otherwise
bool isCooperative() override;

//! \brief return the underlying task handle (implementation specific)
//! \return internal task handle representation
TaskHandle* getHandle() override;
Expand Down

0 comments on commit 5002e64

Please sign in to comment.