Sebastian Lackner : ntdll: Implement TpSetPoolMinThreads.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 1 09:06:23 CDT 2015


Module: wine
Branch: master
Commit: 7d9ec31e19029b726767dafaad25922eb1ad2564
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7d9ec31e19029b726767dafaad25922eb1ad2564

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Wed Jul  1 02:56:26 2015 +0200

ntdll: Implement TpSetPoolMinThreads.

---

 dlls/ntdll/ntdll.spec   |  1 +
 dlls/ntdll/threadpool.c | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index f023443..94194d6 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -973,6 +973,7 @@
 @ stdcall TpAllocPool(ptr ptr)
 @ stdcall TpReleasePool(ptr)
 @ stdcall TpSetPoolMaxThreads(ptr long)
+@ stdcall TpSetPoolMinThreads(ptr long)
 @ stdcall TpSimpleTryPost(ptr ptr ptr)
 @ stdcall -ret64 VerSetConditionMask(int64 long long)
 @ stdcall WinSqmIsOptedIn()
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index 19f288a..6025633 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -1481,6 +1481,41 @@ VOID WINAPI TpSetPoolMaxThreads( TP_POOL *pool, DWORD maximum )
 }
 
 /***********************************************************************
+ *           TpSetPoolMinThreads    (NTDLL.@)
+ */
+BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
+{
+    struct threadpool *this = impl_from_TP_POOL( pool );
+    NTSTATUS status = STATUS_SUCCESS;
+
+    TRACE( "%p %u\n", pool, minimum );
+
+    RtlEnterCriticalSection( &this->cs );
+
+    while (this->num_workers < minimum)
+    {
+        HANDLE thread;
+        status = RtlCreateUserThread( GetCurrentProcess(), NULL, FALSE, NULL, 0, 0,
+                                      threadpool_worker_proc, this, &thread, NULL );
+        if (status != STATUS_SUCCESS)
+            break;
+
+        interlocked_inc( &this->refcount );
+        this->num_workers++;
+        NtClose( thread );
+    }
+
+    if (status == STATUS_SUCCESS)
+    {
+        this->min_workers = minimum;
+        this->max_workers = max( this->min_workers, this->max_workers );
+    }
+
+    RtlLeaveCriticalSection( &this->cs );
+    return !status;
+}
+
+/***********************************************************************
  *           TpSimpleTryPost    (NTDLL.@)
  */
 NTSTATUS WINAPI TpSimpleTryPost( PTP_SIMPLE_CALLBACK callback, PVOID userdata,




More information about the wine-cvs mailing list