diff --git a/README.md b/README.md index b866337..655d405 100644 --- a/README.md +++ b/README.md @@ -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()` - 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". diff --git a/Thread.cpp b/Thread.cpp index cd29d98..eadd1d1 100644 --- a/Thread.cpp +++ b/Thread.cpp @@ -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(this); #ifdef USE_THREAD_NAMES ThreadName = "Thread "; ThreadName = ThreadName + ThreadID; diff --git a/Thread.h b/Thread.h index 0e580a9..87b5088 100644 --- a/Thread.h +++ b/Thread.h @@ -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). diff --git a/ThreadController.cpp b/ThreadController.cpp index 7d8e41c..220edd6 100644 --- a/ThreadController.cpp +++ b/ThreadController.cpp @@ -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){ diff --git a/ThreadController.h b/ThreadController.h index 8e2888c..d13fa4d 100644 --- a/ThreadController.h +++ b/ThreadController.h @@ -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