diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-12-21 02:33:01 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-12-21 02:33:01 +0000 |
commit | d19ca324fcd8df0d62d1f7e8ee2b16c9bdbef0e8 (patch) | |
tree | 67c5394f5e63303ed3190607e4bb581958ce4681 /apps/plugins/alpine_cdc.c | |
parent | bb0358647d68e989d065ea70d95746fd2b6f4cad (diff) | |
download | rockbox-d19ca324fcd8df0d62d1f7e8ee2b16c9bdbef0e8.tar.gz rockbox-d19ca324fcd8df0d62d1f7e8ee2b16c9bdbef0e8.zip |
Lil' tweak to plugins using remove_thread. Just use remove_thread(NULL) to have a thread remove itself. No subsequent yield() is needed either. Small Note: in current scheduler implementation it safe to call remove_thread IFF 1) thread removes itself 2) its state is known to be running (1 implies 2) as any objects with the waiting removed thread will be corrupted (m->thread, q->thread no longer valid or no longer same object if recycled, etc.).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11826 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/alpine_cdc.c')
-rw-r--r-- | apps/plugins/alpine_cdc.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index 65108680c6..9c1bc8bd0b 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c | |||
@@ -202,7 +202,6 @@ struct | |||
202 | /* communication to the worker thread */ | 202 | /* communication to the worker thread */ |
203 | struct | 203 | struct |
204 | { | 204 | { |
205 | struct thread_entry *id; /* Pointer of the thread */ | ||
206 | bool foreground; /* set as long as we're owning the UI */ | 205 | bool foreground; /* set as long as we're owning the UI */ |
207 | bool exiting; /* signal to the thread that we want to exit */ | 206 | bool exiting; /* signal to the thread that we want to exit */ |
208 | bool ended; /* response from the thread, that is has exited */ | 207 | bool ended; /* response from the thread, that is has exited */ |
@@ -1117,8 +1116,7 @@ void thread(void) | |||
1117 | } while (!gTread.exiting); | 1116 | } while (!gTread.exiting); |
1118 | 1117 | ||
1119 | gTread.ended = true; /* acknowledge the exit */ | 1118 | gTread.ended = true; /* acknowledge the exit */ |
1120 | rb->remove_thread(gTread.id); /* commit suicide */ | 1119 | rb->remove_thread(NULL); /* commit suicide */ |
1121 | rb->yield(); /* pass control to other threads, we won't return */ | ||
1122 | } | 1120 | } |
1123 | 1121 | ||
1124 | /* callback to end the TSR plugin, called before a new one gets loaded */ | 1122 | /* callback to end the TSR plugin, called before a new one gets loaded */ |
@@ -1172,8 +1170,8 @@ int main(void* parameter) | |||
1172 | 1170 | ||
1173 | rb->memset(&gTread, 0, sizeof(gTread)); | 1171 | rb->memset(&gTread, 0, sizeof(gTread)); |
1174 | gTread.foreground = true; | 1172 | gTread.foreground = true; |
1175 | gTread.id = rb->create_thread(thread, stack, stacksize, "CDC" | 1173 | rb->create_thread(thread, stack, stacksize, "CDC" |
1176 | IF_PRIO(, PRIORITY_BACKGROUND)); | 1174 | IF_PRIO(, PRIORITY_BACKGROUND)); |
1177 | 1175 | ||
1178 | #ifdef DEBUG | 1176 | #ifdef DEBUG |
1179 | do | 1177 | do |