diff options
author | Christopher Faylor <me@cgf.cx> | 2005-03-27 05:57:38 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-03-27 05:57:38 +0400 |
commit | ec98d19a08c2e4678e8a6f40fea0c9bbeaa4a2c7 (patch) | |
tree | 667b5bf4984c1caa5b3f7df1b2b296e16c394c73 /winsup/cygwin/cygthread.cc | |
parent | 9eba97c0d5d723ce151b38d4bc78bd6fe097336c (diff) |
* wininfo.h (wininfo::timer_active): Delete.
(wininfo::itv): Ditto.
(wininfo::start_time): Ditto.
(wininfo::window_started): Ditto.
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(wininfo::wininfo): Ditto.
(wininfo::lock): New method.
(wininfo::release): Ditto.
* window.cc: Use new lock/acquire wininfo methods throughout.
(wininfo::wininfo): Delete
(wininfo::getitimer): Ditto.
(wininfo::setitimer): Ditto.
(getitimer): Ditto.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
(wininfo::lock): Define new function.
(wininfo::release): Ditto.
(wininfo::process): Delete WM_TIMER handling.
* timer.cc (struct timetracker): Delete it, flags. Add it_interval,
interval_us, sleepto_us, running, init_muto(), syncthread, and gettime().
(ttstart): Make NO_COPY.
(lock_timer_tracker): New class.
(timer_tracker::timer_tracker): Distinguish ttstart case.
(timer_tracker::~timer_tracker): New destructor. Clean out events, and reset
magic.
(timer_tracker::init_muto): New method.
(to_us): Round up as per POSIX.
(timer_thread): Reorganize to match timer_tracker::settime and
timer_tracker::gettime. Call sig_send without wait. Call auto_release.
(timer_tracker::settime): Reorganize logic to avoid race. Call gettime to
recover old value.
(timer_tracker::gettime): New method.
(timer_create): Properly set errno on invalid timerid. Use new
lock_timer_tracker method.
(timer_delete): Ditto. Simplify code slightly.
(timer_gettime): New function.
(fixup_timers_after_fork): Reinit ttstart.
(getitimer): New implementation.
(setitimer): Ditto.
(ualarm): Ditto.
(alarm): Ditto.
* cygwin.din: Export timer_gettime.
* winsup.h: Remove has has_visible_window_station declaration.
* Makefile.in (DLL_OFILES): Add lsearch.o.
* cygthread.h (cygthread::notify_detached): New element.
(cygthread::cygthread): Take optional fourth argument signifying event to
signal on thread completion.
* cygthread.cc (cygthread::stub): Signal notify_detached event, if it exists.
(cygthread::cygthread): Initialize notify_detached from fourth argument.
(cygthread::detach): Wait for notify_detached field is present.
* lsearch.cc: New file.
* search.h: Ditto.
* include/cygwin/version.h: Bump API minor number to 126.
* cygwin.din: Export lsearch, lfind.
Diffstat (limited to 'winsup/cygwin/cygthread.cc')
-rw-r--r-- | winsup/cygwin/cygthread.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 9cdeac84b..11fb047dd 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -26,7 +26,7 @@ DWORD NO_COPY cygthread::main_thread_id; bool NO_COPY cygthread::exiting; /* Initial stub called by cygthread constructor. Performs initial - per-thread initialization and loops waiting for new thread functions + per-thread initialization and loops waiting for another thread function to execute. */ DWORD WINAPI cygthread::stub (VOID *arg) @@ -73,10 +73,11 @@ cygthread::stub (VOID *arg) info->func (info->arg == cygself ? info : info->arg); /* ...so the above should always return */ + HANDLE notify = info->notify_detached; /* If func is NULL, the above function has set that to indicate that it doesn't want to alert anyone with a SetEvent and should just be marked as no longer inuse. Hopefully the function knows - that it is doing. */ + what it is doing. */ if (!info->func) info->release (false); else @@ -88,6 +89,8 @@ cygthread::stub (VOID *arg) info->__name = NULL; SetEvent (info->ev); } + if (notify) + SetEvent (notify); } switch (WaitForSingleObject (info->thread_sync, INFINITE)) { @@ -161,8 +164,8 @@ out: } cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, - const char *name): __name (name), - func (start), arg (param) + const char *name, HANDLE notify) + : __name (name), func (start), arg (param), notify_detached (notify) { thread_printf ("name %s, id %p", name, id); if (h) @@ -310,7 +313,9 @@ cygthread::detach (HANDLE sigwait) DWORD res; if (!sigwait) - res = WaitForSingleObject (*this, INFINITE); + /* If the caller specified a special handle for notification, wait for that. + This assumes that the thread in question is auto releasing. */ + res = WaitForSingleObject (notify_detached ?: *this, INFINITE); else { /* Lower our priority and give priority to the read thread */ |