草庐IT

pthread_sigmask

全部标签

c++ - 在 c++ 的 Windows 线程编程中,pthread_setcanceltype 的替代方案是什么?

在c++的windows线程编程中,pthread_setcanceltype的替代方案是什么? 最佳答案 Windows线程没有取消点,因此无需考虑系统取消类型。因此,在Windows上“取消”一个线程意味着您,开发人员,需要想出一个策略来告诉线程退出。如果它是GUI线程,您可以向其发送WM_QUIT消息。如果它是一个非GUI线程,那么它真的取决于线程在做什么。您需要分析线程并查看是否存在代码可以明确检查线程是否需要继续运行或退出的点。有一个pthreads-win32如果您宁愿避免该问题并在Win32上获得pthreads投诉行

windows - 使用 Windows 线程时,是否可以指定一个缓冲区用于线程的堆栈,类似于 pthread_attr_setstack()?

pthreads允许用户提供一block内存用于线程堆栈:size_tstack_size=1024*1024*4;void*stack=malloc(stack_size);pthread_attr_tattributes;pthread_attr_init(&attributes);pthread_attr_setstack(&attributes,stack,stack_size);pthread_tthread_id;pthread_create(&thread_id,&attributes,worker_function,NULLWindows线程是否提供类似的功能?Crea

c++ - 你如何为 x64 编译静态 pthread-win32 库?

看起来已经做了一些工作来制作pthread-win32使用x64,但没有构建说明。我曾尝试使用VisualStudiox64交叉工具命令提示进行简单构建,但是当我尝试从x64应用程序链接到lib时,它看不到任何函数导出。它似乎仍在将lib编译为x86或其他东西。我什至尝试过将/MACHINE添加到makefile的适当位置,但没有帮助。有人让这个工作吗? 最佳答案 您可以使用vcpkghere.这是C++的Windows包管理器。它支持pthread构建以及其他开源库。我想使用静态pthread库。当我下载pthread时,我得到了

php - 在 php 中使用 pthread 进行后台处理

我正在尝试使用pthread在php中实现多线程发送电子邮件。这里的基本思想是将电子邮件作为后台作业发送,这样用户就不必等待任务完成。我有一项服务,用户PHPMailer发送电子邮件及其工作正常。我正在使用以下代码进行多线程classThreadWorkerServiceextends\Thread{private$_runMethod;private$_vars;private$_autoloderPath;function__construct($vars){$this->_vars=$vars;$reflector=new\ReflectionClass('Composer\Au

c - 当 pthread 在等待互斥体时死亡会发生什么?

如果一个进程有三个线程,T1、T2和T3,并且所有三个线程都试图获取互斥锁M1上的锁,我理解一个将获取互斥锁,而另外两个将等待直到它们获取互斥锁。如果我使用pthread_mutexattr_setrobust()使线程健壮,那么我明白如果T1持有M1,并且T1在释放M1之前终止,T2将被EOWNERDEAD的返回值唤醒。然后T2可以清理protected资源的状态。现在,如果T1拥有M1而T2和T3正在等待M1,会发生什么情况。T2终止。发生什么了?当T1释放M1时,互斥体是否直接进入T3?T3是否获得了EOWNERDEAD,或者它只是看起来T3就像什么都没有发生并且不需要清理?似乎

PHP Pthread - 无法获取 DOMDocument

我正在尝试编写php线程代码。我正在构造函数中创建一个DOMDocument,但由于某种原因,新创建的文档虽然已分配给成员变量,但却消失了。代码list1:classworkerThreadextendsThread{private$document;private$i;publicfunction__construct($i){$this->document=newDOMDocument();$this->i=$i;}publicfunctionrun(){try{$root=$this->document->createElement("Root");//can'tfetchthi

php - 如何让 pthreads 在 PHP 中工作?

我正在使用wampserver在我的本地计算机上测试和运行wordpress代码。为了运行pthread,我遵循了以下步骤:1)我从http://windows.php.net/downloads/pecl/releases/pthreads/0.44/得到了pthreadzip文件(我的机器有php5.3.13并从上面的链接下载了php_pthreads-0.44-5.3-ts-vc9-x86.zip文件)。2)解压缩zip文件。将php_pthreads.dll移动到C:\wamp\bin\php\php5.3.13\ext目录。3)将pthreadVC2.dll移动到C:\wam

PHP-FPM 和 pthreads

我正在使用PHP-FPM运行Phalcon应用程序,并且刚刚安装了pthreads,因此我可以开始异步运行任务。我目前有pthreads使用命令行界面工作:workerId=$id;}publicfunctionrun(){usleep(2000000);//2secondsecho"Worker{$this->workerId}ran".PHP_EOL;}}//Workerpool$workers=[];//Initializeandstartthethreadsforeach(range(0,5)as$i){$workers[$i]=newWorkerThreads($i);$wo

php - Apache2,线程。 fatal error 。 pthreads 不支持 apache2handler SAPI

我的ubuntu上有apache2网络服务器。我需要安装pthreads,所以我从rep(复制到/ext/)克隆了php7和pthreads的源代码。我为php安装了所有库,然后运行​​./buildconf和./configure--prefix=/usr--with-config-file-path=/etc--enable-bcmath--enable-calendar--enable-cli--enable-debug--enable-dba--enable-exif--enable-ftp--enable-gd-native-ttf--enable-mbregex--enab

php - 在 Ubuntu 上的 PHP+Apache2 中启用线程安全 - 使用 pthreads 从源代码编译 php

在我通过apt-get安装Apache2和PHP5后,我试图让pthreads在我的Ubuntu服务器(14.04)上运行。我的初始步骤:已安装apache2-apt-getinstallapache2使用常用模块安装php5apt-getinstallphp5libapache2-mod-php5php5-mcrypt...然后我按照本教程让pthreads运行(Usercontributedmanualonphp.net):1-GetPHPversionForthisexamplewewilluseversion:5.4.36#wgethttp://www.php.net/dist