winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2015
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
567 discussions
Start a n
N
ew thread
Sebastian Lackner : ntdll: Implement TpCallbackUnloadDllOnCompletion.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: 8965511957d3d9f92fa0d6f41e5961d8a867f927 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8965511957d3d9f92fa0d6f41…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:58:23 2015 +0200 ntdll: Implement TpCallbackUnloadDllOnCompletion. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/threadpool.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 03f3af2..134a3f7 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -978,6 +978,7 @@ @ stdcall TpCallbackReleaseMutexOnCompletion(ptr long) @ stdcall TpCallbackReleaseSemaphoreOnCompletion(ptr long long) @ stdcall TpCallbackSetEventOnCompletion(ptr long) +@ stdcall TpCallbackUnloadDllOnCompletion(ptr ptr) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index af4f620..eeb275f 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -210,6 +210,7 @@ struct threadpool_instance HANDLE semaphore; LONG semaphore_count; HANDLE event; + HMODULE library; } cleanup; }; @@ -1644,6 +1645,7 @@ static void CALLBACK threadpool_worker_proc( void *param ) instance.cleanup.semaphore = NULL; instance.cleanup.semaphore_count = 0; instance.cleanup.event = NULL; + instance.cleanup.library = NULL; switch (object->type) { @@ -1696,7 +1698,12 @@ static void CALLBACK threadpool_worker_proc( void *param ) } if (instance.cleanup.event) { - NtSetEvent( instance.cleanup.event, NULL ); + status = NtSetEvent( instance.cleanup.event, NULL ); + if (status != STATUS_SUCCESS) goto skip_cleanup; + } + if (instance.cleanup.library) + { + LdrUnloadDll( instance.cleanup.library ); } skip_cleanup: @@ -1893,6 +1900,19 @@ VOID WINAPI TpCallbackSetEventOnCompletion( TP_CALLBACK_INSTANCE *instance, HAND } /*********************************************************************** + * TpCallbackUnloadDllOnCompletion (NTDLL.@) + */ +VOID WINAPI TpCallbackUnloadDllOnCompletion( TP_CALLBACK_INSTANCE *instance, HMODULE module ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + + TRACE( "%p %p\n", instance, module ); + + if (!this->cleanup.library) + this->cleanup.library = module; +} + +/*********************************************************************** * TpPostWork (NTDLL.@) */ VOID WINAPI TpPostWork( TP_WORK *work )
1
0
0
0
Sebastian Lackner : ntdll: Implement TpCallbackSetEventOnCompletion.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: 15110b1770e61593a69a726a6a0238a895fd2b86 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=15110b1770e61593a69a726a6…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:57:53 2015 +0200 ntdll: Implement TpCallbackSetEventOnCompletion. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/threadpool.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 8d89c58..03f3af2 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -977,6 +977,7 @@ @ stdcall TpCallbackMayRunLong(ptr) @ stdcall TpCallbackReleaseMutexOnCompletion(ptr long) @ stdcall TpCallbackReleaseSemaphoreOnCompletion(ptr long long) +@ stdcall TpCallbackSetEventOnCompletion(ptr long) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 46ed810..af4f620 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -209,6 +209,7 @@ struct threadpool_instance HANDLE mutex; HANDLE semaphore; LONG semaphore_count; + HANDLE event; } cleanup; }; @@ -1642,6 +1643,7 @@ static void CALLBACK threadpool_worker_proc( void *param ) instance.cleanup.mutex = NULL; instance.cleanup.semaphore = NULL; instance.cleanup.semaphore_count = 0; + instance.cleanup.event = NULL; switch (object->type) { @@ -1689,7 +1691,12 @@ static void CALLBACK threadpool_worker_proc( void *param ) } if (instance.cleanup.semaphore) { - NtReleaseSemaphore( instance.cleanup.semaphore, instance.cleanup.semaphore_count, NULL ); + status = NtReleaseSemaphore( instance.cleanup.semaphore, instance.cleanup.semaphore_count, NULL ); + if (status != STATUS_SUCCESS) goto skip_cleanup; + } + if (instance.cleanup.event) + { + NtSetEvent( instance.cleanup.event, NULL ); } skip_cleanup: @@ -1873,6 +1880,19 @@ VOID WINAPI TpCallbackReleaseSemaphoreOnCompletion( TP_CALLBACK_INSTANCE *instan } /*********************************************************************** + * TpCallbackSetEventOnCompletion (NTDLL.@) + */ +VOID WINAPI TpCallbackSetEventOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE event ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + + TRACE( "%p %p\n", instance, event ); + + if (!this->cleanup.event) + this->cleanup.event = event; +} + +/*********************************************************************** * TpPostWork (NTDLL.@) */ VOID WINAPI TpPostWork( TP_WORK *work )
1
0
0
0
Sebastian Lackner : ntdll/tests: Add tests for TpCallbackReleaseSemaphoreOnCompletion and finalization callback.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: 3dc1c6442aad69f15b0c44e0144815de31c65de9 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3dc1c6442aad69f15b0c44e01…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:57:16 2015 +0200 ntdll/tests: Add tests for TpCallbackReleaseSemaphoreOnCompletion and finalization callback. --- dlls/ntdll/tests/threadpool.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/dlls/ntdll/tests/threadpool.c b/dlls/ntdll/tests/threadpool.c index e920300..62bd064 100644 --- a/dlls/ntdll/tests/threadpool.c +++ b/dlls/ntdll/tests/threadpool.c @@ -25,6 +25,7 @@ static NTSTATUS (WINAPI *pTpAllocCleanupGroup)(TP_CLEANUP_GROUP **); static NTSTATUS (WINAPI *pTpAllocPool)(TP_POOL **,PVOID); static NTSTATUS (WINAPI *pTpAllocWork)(TP_WORK **,PTP_WORK_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); static NTSTATUS (WINAPI *pTpCallbackMayRunLong)(TP_CALLBACK_INSTANCE *); +static VOID (WINAPI *pTpCallbackReleaseSemaphoreOnCompletion)(TP_CALLBACK_INSTANCE *,HANDLE,DWORD); static VOID (WINAPI *pTpPostWork)(TP_WORK *); static VOID (WINAPI *pTpReleaseCleanupGroup)(TP_CLEANUP_GROUP *); static VOID (WINAPI *pTpReleaseCleanupGroupMembers)(TP_CLEANUP_GROUP *,BOOL,PVOID); @@ -55,6 +56,7 @@ static BOOL init_threadpool(void) NTDLL_GET_PROC(TpAllocPool); NTDLL_GET_PROC(TpAllocWork); NTDLL_GET_PROC(TpCallbackMayRunLong); + NTDLL_GET_PROC(TpCallbackReleaseSemaphoreOnCompletion); NTDLL_GET_PROC(TpPostWork); NTDLL_GET_PROC(TpReleaseCleanupGroup); NTDLL_GET_PROC(TpReleaseCleanupGroupMembers); @@ -431,6 +433,71 @@ static void test_tp_group_cancel(void) CloseHandle(semaphores[1]); } +static void CALLBACK instance_semaphore_completion_cb(TP_CALLBACK_INSTANCE *instance, void *userdata) +{ + HANDLE *semaphores = userdata; + trace("Running instance completion callback\n"); + pTpCallbackReleaseSemaphoreOnCompletion(instance, semaphores[0], 1); +} + +static void CALLBACK instance_finalization_cb(TP_CALLBACK_INSTANCE *instance, void *userdata) +{ + HANDLE *semaphores = userdata; + DWORD result; + + trace("Running instance finalization callback\n"); + + result = WaitForSingleObject(semaphores[0], 100); + ok(result == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", result); + ReleaseSemaphore(semaphores[1], 1, NULL); +} + +static void test_tp_instance(void) +{ + TP_CALLBACK_ENVIRON environment; + HANDLE semaphores[2]; + NTSTATUS status; + TP_POOL *pool; + DWORD result; + + semaphores[0] = CreateSemaphoreW(NULL, 0, 1, NULL); + ok(semaphores[0] != NULL, "failed to create semaphore\n"); + semaphores[1] = CreateSemaphoreW(NULL, 0, 1, NULL); + ok(semaphores[1] != NULL, "failed to create semaphore\n"); + + /* allocate new threadpool */ + pool = NULL; + status = pTpAllocPool(&pool, NULL); + ok(!status, "TpAllocPool failed with status %x\n", status); + ok(pool != NULL, "expected pool != NULL\n"); + + /* test for TpCallbackReleaseSemaphoreOnCompletion */ + memset(&environment, 0, sizeof(environment)); + environment.Version = 1; + environment.Pool = pool; + status = pTpSimpleTryPost(instance_semaphore_completion_cb, semaphores, &environment); + ok(!status, "TpSimpleTryPost failed with status %x\n", status); + result = WaitForSingleObject(semaphores[0], 1000); + ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); + + /* test for finalization callback */ + memset(&environment, 0, sizeof(environment)); + environment.Version = 1; + environment.Pool = pool; + environment.FinalizationCallback = instance_finalization_cb; + status = pTpSimpleTryPost(instance_semaphore_completion_cb, semaphores, &environment); + ok(!status, "TpSimpleTryPost failed with status %x\n", status); + result = WaitForSingleObject(semaphores[0], 1000); + ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); + result = WaitForSingleObject(semaphores[1], 1000); + ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); + + /* cleanup */ + pTpReleasePool(pool); + CloseHandle(semaphores[0]); + CloseHandle(semaphores[1]); +} + START_TEST(threadpool) { if (!init_threadpool()) @@ -440,4 +507,5 @@ START_TEST(threadpool) test_tp_work(); test_tp_work_scheduler(); test_tp_group_cancel(); + test_tp_instance(); }
1
0
0
0
Sebastian Lackner : ntdll: Implement TpCallbackReleaseSemaphoreOnCompletion.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: eb39cb1323046778f4d7c34e3d78bf5840c26010 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=eb39cb1323046778f4d7c34e3…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:56:51 2015 +0200 ntdll: Implement TpCallbackReleaseSemaphoreOnCompletion. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/threadpool.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 4ccb3e7..8d89c58 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -976,6 +976,7 @@ @ stdcall TpCallbackLeaveCriticalSectionOnCompletion(ptr ptr) @ stdcall TpCallbackMayRunLong(ptr) @ stdcall TpCallbackReleaseMutexOnCompletion(ptr long) +@ stdcall TpCallbackReleaseSemaphoreOnCompletion(ptr long long) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 28dd88b..46ed810 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -207,6 +207,8 @@ struct threadpool_instance { CRITICAL_SECTION *critical_section; HANDLE mutex; + HANDLE semaphore; + LONG semaphore_count; } cleanup; }; @@ -1608,6 +1610,7 @@ static void CALLBACK threadpool_worker_proc( void *param ) struct threadpool *pool = param; LARGE_INTEGER timeout; struct list *ptr; + NTSTATUS status; TRACE( "starting worker thread for pool %p\n", pool ); @@ -1637,6 +1640,8 @@ static void CALLBACK threadpool_worker_proc( void *param ) instance.may_run_long = object->may_run_long; instance.cleanup.critical_section = NULL; instance.cleanup.mutex = NULL; + instance.cleanup.semaphore = NULL; + instance.cleanup.semaphore_count = 0; switch (object->type) { @@ -1679,9 +1684,15 @@ static void CALLBACK threadpool_worker_proc( void *param ) } if (instance.cleanup.mutex) { - NtReleaseMutant( instance.cleanup.mutex, NULL ); + status = NtReleaseMutant( instance.cleanup.mutex, NULL ); + if (status != STATUS_SUCCESS) goto skip_cleanup; + } + if (instance.cleanup.semaphore) + { + NtReleaseSemaphore( instance.cleanup.semaphore, instance.cleanup.semaphore_count, NULL ); } + skip_cleanup: RtlEnterCriticalSection( &pool->cs ); pool->num_busy_workers--; object->num_running_callbacks--; @@ -1846,6 +1857,22 @@ VOID WINAPI TpCallbackReleaseMutexOnCompletion( TP_CALLBACK_INSTANCE *instance, } /*********************************************************************** + * TpCallbackReleaseSemaphoreOnCompletion (NTDLL.@) + */ +VOID WINAPI TpCallbackReleaseSemaphoreOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE semaphore, DWORD count ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + + TRACE( "%p %p %u\n", instance, semaphore, count ); + + if (!this->cleanup.semaphore) + { + this->cleanup.semaphore = semaphore; + this->cleanup.semaphore_count = count; + } +} + +/*********************************************************************** * TpPostWork (NTDLL.@) */ VOID WINAPI TpPostWork( TP_WORK *work )
1
0
0
0
Sebastian Lackner : ntdll: Implement TpCallbackReleaseMutexOnCompletion.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: 02ee5bb52da578a7ef71be104666983442e23512 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=02ee5bb52da578a7ef71be104…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:56:14 2015 +0200 ntdll: Implement TpCallbackReleaseMutexOnCompletion. Various internal details about the order and error handling of completion actions are documented in "Concurrent Programming on Windows" by Joe Duffy. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/threadpool.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 5cfcfd7..4ccb3e7 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -975,6 +975,7 @@ @ stdcall TpAllocWork(ptr ptr ptr ptr) @ stdcall TpCallbackLeaveCriticalSectionOnCompletion(ptr ptr) @ stdcall TpCallbackMayRunLong(ptr) +@ stdcall TpCallbackReleaseMutexOnCompletion(ptr long) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 21e5b7d..28dd88b 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -206,6 +206,7 @@ struct threadpool_instance struct { CRITICAL_SECTION *critical_section; + HANDLE mutex; } cleanup; }; @@ -1635,6 +1636,7 @@ static void CALLBACK threadpool_worker_proc( void *param ) instance.threadid = GetCurrentThreadId(); instance.may_run_long = object->may_run_long; instance.cleanup.critical_section = NULL; + instance.cleanup.mutex = NULL; switch (object->type) { @@ -1675,6 +1677,10 @@ static void CALLBACK threadpool_worker_proc( void *param ) { RtlLeaveCriticalSection( instance.cleanup.critical_section ); } + if (instance.cleanup.mutex) + { + NtReleaseMutant( instance.cleanup.mutex, NULL ); + } RtlEnterCriticalSection( &pool->cs ); pool->num_busy_workers--; @@ -1827,6 +1833,19 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance ) } /*********************************************************************** + * TpCallbackReleaseMutexOnCompletion (NTDLL.@) + */ +VOID WINAPI TpCallbackReleaseMutexOnCompletion( TP_CALLBACK_INSTANCE *instance, HANDLE mutex ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + + TRACE( "%p %p\n", instance, mutex ); + + if (!this->cleanup.mutex) + this->cleanup.mutex = mutex; +} + +/*********************************************************************** * TpPostWork (NTDLL.@) */ VOID WINAPI TpPostWork( TP_WORK *work )
1
0
0
0
Sebastian Lackner : ntdll: Implement TpCallbackLeaveCriticalSectionOnCompletion.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: a9dd37be6827e7df90838c604404db1d112ebf42 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a9dd37be6827e7df90838c604…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:55:52 2015 +0200 ntdll: Implement TpCallbackLeaveCriticalSectionOnCompletion. An instance can only have one completion of each type, trying to add a second one leads to an exception on Windows. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/threadpool.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 5a698c4..5cfcfd7 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -973,6 +973,7 @@ @ stdcall TpAllocCleanupGroup(ptr) @ stdcall TpAllocPool(ptr ptr) @ stdcall TpAllocWork(ptr ptr ptr ptr) +@ stdcall TpCallbackLeaveCriticalSectionOnCompletion(ptr ptr) @ stdcall TpCallbackMayRunLong(ptr) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index a0090c0..21e5b7d 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -203,6 +203,10 @@ struct threadpool_instance struct threadpool_object *object; DWORD threadid; BOOL may_run_long; + struct + { + CRITICAL_SECTION *critical_section; + } cleanup; }; /* internal threadpool group representation */ @@ -1630,6 +1634,7 @@ static void CALLBACK threadpool_worker_proc( void *param ) instance.object = object; instance.threadid = GetCurrentThreadId(); instance.may_run_long = object->may_run_long; + instance.cleanup.critical_section = NULL; switch (object->type) { @@ -1665,6 +1670,12 @@ static void CALLBACK threadpool_worker_proc( void *param ) TRACE( "callback %p returned\n", object->finalization_callback ); } + /* Execute cleanup tasks. */ + if (instance.cleanup.critical_section) + { + RtlLeaveCriticalSection( instance.cleanup.critical_section ); + } + RtlEnterCriticalSection( &pool->cs ); pool->num_busy_workers--; object->num_running_callbacks--; @@ -1753,6 +1764,19 @@ NTSTATUS WINAPI TpAllocWork( TP_WORK **out, PTP_WORK_CALLBACK callback, PVOID us } /*********************************************************************** + * TpCallbackLeaveCriticalSectionOnCompletion (NTDLL.@) + */ +VOID WINAPI TpCallbackLeaveCriticalSectionOnCompletion( TP_CALLBACK_INSTANCE *instance, CRITICAL_SECTION *crit ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + + TRACE( "%p %p\n", instance, crit ); + + if (!this->cleanup.critical_section) + this->cleanup.critical_section = crit; +} + +/*********************************************************************** * TpCallbackMayRunLong (NTDLL.@) */ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
1
0
0
0
Sebastian Lackner : ntdll: Implement instance objects and the TpCallbackMayRunLong function.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: eb974bcd7a4eb6e0205c6309f48b885701f3a56f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=eb974bcd7a4eb6e0205c6309f…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:55:30 2015 +0200 ntdll: Implement instance objects and the TpCallbackMayRunLong function. The instance is marked as long-running even if TpCallbackMayRunLong fails, a second call will lead to an exception on Windows. --- dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/tests/threadpool.c | 9 ++++ dlls/ntdll/threadpool.c | 98 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 98 insertions(+), 10 deletions(-) diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 4b5ece5..5a698c4 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -973,6 +973,7 @@ @ stdcall TpAllocCleanupGroup(ptr) @ stdcall TpAllocPool(ptr ptr) @ stdcall TpAllocWork(ptr ptr ptr ptr) +@ stdcall TpCallbackMayRunLong(ptr) @ stdcall TpPostWork(ptr) @ stdcall TpReleaseCleanupGroup(ptr) @ stdcall TpReleaseCleanupGroupMembers(ptr long ptr) diff --git a/dlls/ntdll/tests/threadpool.c b/dlls/ntdll/tests/threadpool.c index 2d64471..e920300 100644 --- a/dlls/ntdll/tests/threadpool.c +++ b/dlls/ntdll/tests/threadpool.c @@ -24,6 +24,7 @@ static HMODULE hntdll = 0; static NTSTATUS (WINAPI *pTpAllocCleanupGroup)(TP_CLEANUP_GROUP **); static NTSTATUS (WINAPI *pTpAllocPool)(TP_POOL **,PVOID); static NTSTATUS (WINAPI *pTpAllocWork)(TP_WORK **,PTP_WORK_CALLBACK,PVOID,TP_CALLBACK_ENVIRON *); +static NTSTATUS (WINAPI *pTpCallbackMayRunLong)(TP_CALLBACK_INSTANCE *); static VOID (WINAPI *pTpPostWork)(TP_WORK *); static VOID (WINAPI *pTpReleaseCleanupGroup)(TP_CLEANUP_GROUP *); static VOID (WINAPI *pTpReleaseCleanupGroupMembers)(TP_CLEANUP_GROUP *,BOOL,PVOID); @@ -53,6 +54,7 @@ static BOOL init_threadpool(void) NTDLL_GET_PROC(TpAllocCleanupGroup); NTDLL_GET_PROC(TpAllocPool); NTDLL_GET_PROC(TpAllocWork); + NTDLL_GET_PROC(TpCallbackMayRunLong); NTDLL_GET_PROC(TpPostWork); NTDLL_GET_PROC(TpReleaseCleanupGroup); NTDLL_GET_PROC(TpReleaseCleanupGroupMembers); @@ -312,8 +314,15 @@ static DWORD group_cancel_tid; static void CALLBACK group_cancel_cb(TP_CALLBACK_INSTANCE *instance, void *userdata) { HANDLE *semaphores = userdata; + NTSTATUS status; DWORD result; + trace("Running group cancel callback\n"); + + status = pTpCallbackMayRunLong(instance); + ok(status == STATUS_TOO_MANY_THREADS || broken(status == 1) /* Win Vista / 2008 */, + "expected STATUS_TOO_MANY_THREADS, got %08x\n", status); + result = WaitForSingleObject(semaphores[0], 1000); ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); ReleaseSemaphore(semaphores[1], 1, NULL); diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 4ae81b0..a0090c0 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -173,6 +173,7 @@ struct threadpool_object PVOID userdata; PTP_CLEANUP_GROUP_CANCEL_CALLBACK group_cancel_callback; PTP_SIMPLE_CALLBACK finalization_callback; + BOOL may_run_long; HMODULE race_dll; /* information about the group, locked via .group->cs */ struct list group_entry; @@ -196,6 +197,14 @@ struct threadpool_object } u; }; +/* internal threadpool instance representation */ +struct threadpool_instance +{ + struct threadpool_object *object; + DWORD threadid; + BOOL may_run_long; +}; + /* internal threadpool group representation */ struct threadpool_group { @@ -223,6 +232,11 @@ static inline struct threadpool_group *impl_from_TP_CLEANUP_GROUP( TP_CLEANUP_GR return (struct threadpool_group *)group; } +static inline struct threadpool_instance *impl_from_TP_CALLBACK_INSTANCE( TP_CALLBACK_INSTANCE *instance ) +{ + return (struct threadpool_instance *)instance; +} + static void CALLBACK threadpool_worker_proc( void *param ); static void tp_object_submit( struct threadpool_object *object ); static void tp_object_shutdown( struct threadpool_object *object ); @@ -1375,6 +1389,7 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->userdata = userdata; object->group_cancel_callback = NULL; object->finalization_callback = NULL; + object->may_run_long = 0; object->race_dll = NULL; memset( &object->group_entry, 0, sizeof(object->group_entry) ); @@ -1393,9 +1408,14 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->group = impl_from_TP_CLEANUP_GROUP( environment->CleanupGroup ); object->group_cancel_callback = environment->CleanupGroupCancelCallback; object->finalization_callback = environment->FinalizationCallback; + object->may_run_long = environment->u.s.LongFunction != 0; object->race_dll = environment->RaceDll; - WARN( "environment not fully implemented yet\n" ); + if (environment->ActivationContext) + FIXME( "activation context not supported yet\n" ); + + if (environment->u.s.Persistent) + FIXME( "persistent threads not supported yet\n" ); } if (object->race_dll) @@ -1578,6 +1598,8 @@ static BOOL tp_object_release( struct threadpool_object *object ) */ static void CALLBACK threadpool_worker_proc( void *param ) { + TP_CALLBACK_INSTANCE *callback_instance; + struct threadpool_instance instance; struct threadpool *pool = param; LARGE_INTEGER timeout; struct list *ptr; @@ -1603,22 +1625,28 @@ static void CALLBACK threadpool_worker_proc( void *param ) pool->num_busy_workers++; RtlLeaveCriticalSection( &pool->cs ); + /* Initialize threadpool instance struct. */ + callback_instance = (TP_CALLBACK_INSTANCE *)&instance; + instance.object = object; + instance.threadid = GetCurrentThreadId(); + instance.may_run_long = object->may_run_long; + switch (object->type) { case TP_OBJECT_TYPE_SIMPLE: { - TRACE( "executing simple callback %p(NULL, %p)\n", - object->u.simple.callback, object->userdata ); - object->u.simple.callback( NULL, object->userdata ); + TRACE( "executing simple callback %p(%p, %p)\n", + object->u.simple.callback, callback_instance, object->userdata ); + object->u.simple.callback( callback_instance, object->userdata ); TRACE( "callback %p returned\n", object->u.simple.callback ); break; } case TP_OBJECT_TYPE_WORK: { - TRACE( "executing work callback %p(NULL, %p, %p)\n", - object->u.work.callback, object->userdata, object ); - object->u.work.callback( NULL, object->userdata, (TP_WORK *)object ); + TRACE( "executing work callback %p(%p, %p, %p)\n", + object->u.work.callback, callback_instance, object->userdata, object ); + object->u.work.callback( callback_instance, object->userdata, (TP_WORK *)object ); TRACE( "callback %p returned\n", object->u.work.callback ); break; } @@ -1631,9 +1659,9 @@ static void CALLBACK threadpool_worker_proc( void *param ) /* Execute finalization callback. */ if (object->finalization_callback) { - TRACE( "executing finalization callback %p(NULL, %p)\n", - object->finalization_callback, object->userdata ); - object->finalization_callback( NULL, object->userdata ); + TRACE( "executing finalization callback %p(%p, %p)\n", + object->finalization_callback, callback_instance, object->userdata ); + object->finalization_callback( callback_instance, object->userdata ); TRACE( "callback %p returned\n", object->finalization_callback ); } @@ -1725,6 +1753,56 @@ NTSTATUS WINAPI TpAllocWork( TP_WORK **out, PTP_WORK_CALLBACK callback, PVOID us } /*********************************************************************** + * TpCallbackMayRunLong (NTDLL.@) + */ +NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance ) +{ + struct threadpool_instance *this = impl_from_TP_CALLBACK_INSTANCE( instance ); + struct threadpool_object *object = this->object; + struct threadpool *pool; + NTSTATUS status = STATUS_SUCCESS; + + TRACE( "%p\n", instance ); + + if (this->threadid != GetCurrentThreadId()) + { + ERR("called from wrong thread, ignoring\n"); + return STATUS_UNSUCCESSFUL; /* FIXME */ + } + + if (this->may_run_long) + return STATUS_SUCCESS; + + pool = object->pool; + RtlEnterCriticalSection( &pool->cs ); + + /* Start new worker threads if required. */ + if (pool->num_busy_workers >= pool->num_workers) + { + if (pool->num_workers < pool->max_workers) + { + HANDLE thread; + status = RtlCreateUserThread( GetCurrentProcess(), NULL, FALSE, NULL, 0, 0, + threadpool_worker_proc, pool, &thread, NULL ); + if (status == STATUS_SUCCESS) + { + interlocked_inc( &pool->refcount ); + pool->num_workers++; + NtClose( thread ); + } + } + else + { + status = STATUS_TOO_MANY_THREADS; + } + } + + RtlLeaveCriticalSection( &pool->cs ); + this->may_run_long = TRUE; + return status; +} + +/*********************************************************************** * TpPostWork (NTDLL.@) */ VOID WINAPI TpPostWork( TP_WORK *work )
1
0
0
0
Sebastian Lackner : ntdll: Implement threadpool RaceDll environment variable.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: 8fc2430c2a5359fbad811c7f7f51eb0b262ba456 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8fc2430c2a5359fbad811c7f7…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:53:44 2015 +0200 ntdll: Implement threadpool RaceDll environment variable. --- dlls/ntdll/threadpool.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 0133e66..4ae81b0 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -173,6 +173,7 @@ struct threadpool_object PVOID userdata; PTP_CLEANUP_GROUP_CANCEL_CALLBACK group_cancel_callback; PTP_SIMPLE_CALLBACK finalization_callback; + HMODULE race_dll; /* information about the group, locked via .group->cs */ struct list group_entry; BOOL is_group_member; @@ -1374,6 +1375,7 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->userdata = userdata; object->group_cancel_callback = NULL; object->finalization_callback = NULL; + object->race_dll = NULL; memset( &object->group_entry, 0, sizeof(object->group_entry) ); object->is_group_member = FALSE; @@ -1391,10 +1393,14 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->group = impl_from_TP_CLEANUP_GROUP( environment->CleanupGroup ); object->group_cancel_callback = environment->CleanupGroupCancelCallback; object->finalization_callback = environment->FinalizationCallback; + object->race_dll = environment->RaceDll; WARN( "environment not fully implemented yet\n" ); } + if (object->race_dll) + LdrAddRefDll( 0, object->race_dll ); + TRACE( "allocated object %p of type %u\n", object, object->type ); /* For simple callbacks we have to run tp_object_submit before adding this object @@ -1560,6 +1566,9 @@ static BOOL tp_object_release( struct threadpool_object *object ) tp_threadpool_unlock( object->pool ); + if (object->race_dll) + LdrUnloadDll( object->race_dll ); + RtlFreeHeap( GetProcessHeap(), 0, object ); return TRUE; }
1
0
0
0
Sebastian Lackner : ntdll: Add support for threadpool finalization callback.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: fa114f122b066e1b9b0f90d45c5a2ce33be386d5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fa114f122b066e1b9b0f90d45…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:53:26 2015 +0200 ntdll: Add support for threadpool finalization callback. --- dlls/ntdll/threadpool.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index 93d9b28..0133e66 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -172,6 +172,7 @@ struct threadpool_object struct threadpool_group *group; PVOID userdata; PTP_CLEANUP_GROUP_CANCEL_CALLBACK group_cancel_callback; + PTP_SIMPLE_CALLBACK finalization_callback; /* information about the group, locked via .group->cs */ struct list group_entry; BOOL is_group_member; @@ -1372,6 +1373,7 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->group = NULL; object->userdata = userdata; object->group_cancel_callback = NULL; + object->finalization_callback = NULL; memset( &object->group_entry, 0, sizeof(object->group_entry) ); object->is_group_member = FALSE; @@ -1388,6 +1390,7 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa object->group = impl_from_TP_CLEANUP_GROUP( environment->CleanupGroup ); object->group_cancel_callback = environment->CleanupGroupCancelCallback; + object->finalization_callback = environment->FinalizationCallback; WARN( "environment not fully implemented yet\n" ); } @@ -1616,6 +1619,15 @@ static void CALLBACK threadpool_worker_proc( void *param ) break; } + /* Execute finalization callback. */ + if (object->finalization_callback) + { + TRACE( "executing finalization callback %p(NULL, %p)\n", + object->finalization_callback, object->userdata ); + object->finalization_callback( NULL, object->userdata ); + TRACE( "callback %p returned\n", object->finalization_callback ); + } + RtlEnterCriticalSection( &pool->cs ); pool->num_busy_workers--; object->num_running_callbacks--;
1
0
0
0
Sebastian Lackner : ntdll/tests: Add tests for threadpool group cancel callback.
by Alexandre Julliard
02 Jul '15
02 Jul '15
Module: wine Branch: master Commit: e8d4b403863c436b6944b67987f0341d5602204c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e8d4b403863c436b6944b6798…
Author: Sebastian Lackner <sebastian(a)fds-team.de> Date: Wed Jul 1 22:53:09 2015 +0200 ntdll/tests: Add tests for threadpool group cancel callback. --- dlls/ntdll/tests/threadpool.c | 116 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/dlls/ntdll/tests/threadpool.c b/dlls/ntdll/tests/threadpool.c index b261cd1..2d64471 100644 --- a/dlls/ntdll/tests/threadpool.c +++ b/dlls/ntdll/tests/threadpool.c @@ -307,6 +307,121 @@ static void test_tp_work_scheduler(void) pTpReleasePool(pool); } +static DWORD group_cancel_tid; + +static void CALLBACK group_cancel_cb(TP_CALLBACK_INSTANCE *instance, void *userdata) +{ + HANDLE *semaphores = userdata; + DWORD result; + trace("Running group cancel callback\n"); + result = WaitForSingleObject(semaphores[0], 1000); + ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); + ReleaseSemaphore(semaphores[1], 1, NULL); +} + +static void CALLBACK group_cancel_cleanup_release_cb(void *object, void *userdata) +{ + HANDLE *semaphores = userdata; + trace("Running group cancel cleanup release callback\n"); + group_cancel_tid = GetCurrentThreadId(); + ReleaseSemaphore(semaphores[0], 1, NULL); +} + +static void CALLBACK group_cancel_cleanup_increment_cb(void *object, void *userdata) +{ + trace("Running group cancel cleanup increment callback\n"); + group_cancel_tid = GetCurrentThreadId(); + InterlockedIncrement((LONG *)userdata); +} + +static void CALLBACK unexpected_cb(TP_CALLBACK_INSTANCE *instance, void *userdata) +{ + ok(0, "Unexpected callback\n"); +} + +static void test_tp_group_cancel(void) +{ + TP_CALLBACK_ENVIRON environment; + TP_CLEANUP_GROUP *group; + LONG userdata, userdata2; + HANDLE semaphores[2]; + NTSTATUS status; + TP_WORK *work; + TP_POOL *pool; + DWORD result; + int i; + + semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL); + ok(semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError()); + semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL); + ok(semaphores[1] != NULL, "CreateSemaphoreA failed %u\n", GetLastError()); + + /* allocate new threadpool with only one thread */ + pool = NULL; + status = pTpAllocPool(&pool, NULL); + ok(!status, "TpAllocPool failed with status %x\n", status); + ok(pool != NULL, "expected pool != NULL\n"); + pTpSetPoolMaxThreads(pool, 1); + + /* allocate a cleanup group */ + group = NULL; + status = pTpAllocCleanupGroup(&group); + ok(!status, "TpAllocCleanupGroup failed with status %x\n", status); + ok(group != NULL, "expected pool != NULL\n"); + + /* test execution of cancellation callback */ + memset(&environment, 0, sizeof(environment)); + environment.Version = 1; + environment.Pool = pool; + status = pTpSimpleTryPost(group_cancel_cb, semaphores, &environment); + ok(!status, "TpSimpleTryPost failed with status %x\n", status); + + memset(&environment, 0, sizeof(environment)); + environment.Version = 1; + environment.Pool = pool; + environment.CleanupGroup = group; + environment.CleanupGroupCancelCallback = group_cancel_cleanup_release_cb; + status = pTpSimpleTryPost(unexpected_cb, NULL, &environment); + ok(!status, "TpSimpleTryPost failed with status %x\n", status); + + group_cancel_tid = 0xdeadbeef; + pTpReleaseCleanupGroupMembers(group, TRUE, semaphores); + result = WaitForSingleObject(semaphores[1], 1000); + ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result); + ok(group_cancel_tid == GetCurrentThreadId(), "expected tid %x, got %x\n", + GetCurrentThreadId(), group_cancel_tid); + + /* test cancellation callback for objects with multiple instances */ + work = NULL; + memset(&environment, 0, sizeof(environment)); + environment.Version = 1; + environment.Pool = pool; + environment.CleanupGroup = group; + environment.CleanupGroupCancelCallback = group_cancel_cleanup_increment_cb; + status = pTpAllocWork(&work, work_cb, &userdata, &environment); + ok(!status, "TpAllocWork failed with status %x\n", status); + ok(work != NULL, "expected work != NULL\n"); + + /* post 10 identical work items at once */ + userdata = userdata2 = 0; + for (i = 0; i < 10; i++) + pTpPostWork(work); + + /* check if we get multiple cancellation callbacks */ + group_cancel_tid = 0xdeadbeef; + pTpReleaseCleanupGroupMembers(group, TRUE, &userdata2); + ok(userdata <= 8, "expected userdata <= 8, got %u\n", userdata); + ok(userdata2 == 1, "expected only one cancellation callback, got %u\n", userdata2); + ok(group_cancel_tid == GetCurrentThreadId(), "expected tid %x, got %x\n", + GetCurrentThreadId(), group_cancel_tid); + + /* cleanup */ + pTpReleaseCleanupGroup(group); + pTpReleasePool(pool); + CloseHandle(semaphores[0]); + CloseHandle(semaphores[1]); +} + START_TEST(threadpool) { if (!init_threadpool()) @@ -315,4 +430,5 @@ START_TEST(threadpool) test_tp_simple(); test_tp_work(); test_tp_work_scheduler(); + test_tp_group_cancel(); }
1
0
0
0
← Newer
1
...
48
49
50
51
52
53
54
...
57
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Results per page:
10
25
50
100
200