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

Use uintptr_t type for ThreadID #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ interrupts(); // This will enable the interrupts egain. DO NOT FORGET!
(Basically,the logic is: (reached time AND is enabled?).
- `void Thread::onRun(<function>)` - The target callback function to be called.
- `void Thread::run()` - Runs the thread (executes the callback function).
- `int Thread::ThreadID` - Theoretically, it's the memory address. It's unique, and can
- `uintptr_t Thread::ThreadID` - Theoretically, it's the memory address. It's unique, and can
be used to compare if two threads are identical.
- `int Thread::ThreadName` - A human-readable thread name.
Default is "Thread ThreadID", eg.: "Thread 141515".
Expand Down
2 changes: 1 addition & 1 deletion Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Thread::Thread(void (*callback)(void), unsigned long _interval){
_cached_next_run = 0;
last_run = millis();

ThreadID = (int)this;
ThreadID = reinterpret_cast<uintptr_t>(this);
#ifdef USE_THREAD_NAMES
ThreadName = "Thread ";
ThreadName = ThreadName + ThreadID;
Expand Down
2 changes: 1 addition & 1 deletion Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Thread{
bool enabled;

// ID of the Thread (initialized from memory adr.)
int ThreadID;
uintptr_t ThreadID;

#ifdef USE_THREAD_NAMES
// Thread Name (used for better UI).
Expand Down
2 changes: 1 addition & 1 deletion ThreadController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool ThreadController::add(Thread* _thread){
return false;
}

void ThreadController::remove(int id){
void ThreadController::remove(uintptr_t id){
// Find Threads with the id, and removes
for(int i = 0; i < MAX_THREADS; i++){
if(thread[i]->ThreadID == id){
Expand Down
2 changes: 1 addition & 1 deletion ThreadController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ThreadController: public Thread{
bool add(Thread* _thread);

// remove the thread (given the Thread* or ThreadID)
void remove(int _id);
void remove(uintptr_t _id);
void remove(Thread* _thread);

// Removes all threads
Expand Down