Comments (6)
Yes, I should think so. That is, if I understand you correctly and you have more than one PDF to stamp in a single request.
Start with the examples, all of them even if you think you are not interested in that particular part of multi-threading. They have advice too informal for the PHP manual. Then, there's the PHP manual, which is as much as makes no difference up to date ( at the moment ), and includes inline example for almost everything you need to use. Then when you have read all that, there's bug reports that have been filed and my responses, and solutions to them. After all that, there's me, feel free to contact me directly.
from pthreads.
How can I contact you :) Sorry, a new github user here.. Couldn't found any way to send you message..
The system basically is:
function1 -> sends info to plugin1 -> receives info from plugin1 (function2 waits until function 1 finished this process)
function2 -> sends info to plugin2 -> receives info from plugin2 (function3 waits...)
..
..
I've 13 functions like that and it takes 3-4 seconds for the plugin to stamp each pdf file. So in total it takes 25-30 seconds and it's way too long.
from pthreads.
You're contacting me now !!!
You can email pthreads at the pthreads website dot org too ...
from pthreads.
if ($tarih_sql == true)
{
$urun_id = $db->VeriCek($Id, 'siparisler', 'urun_id');
$pdf_url = $ykd->PdfGen($Id);
$urun_pdf_url2 = $db->VeriCek($urun_id, 'urunler', 'pdf_url2');
if ($urun_pdf_url2 != '') { $pdf_url2 = $ykd->PdfGen2($Id, '0', '2'); $pdf_url_sql .= ", pdf_url2='$pdf_url2'"; }
$urun_pdf_url3 = $db->VeriCek($urun_id, 'urunler', 'pdf_url3');
if ($urun_pdf_url3 != '') { $pdf_url3 = $ykd->PdfGen3($Id, '0', '3'); $pdf_url_sql .= ", pdf_url3='$pdf_url3'"; }
$urun_pdf_url4 = $db->VeriCek($urun_id, 'urunler', 'pdf_url4');
if ($urun_pdf_url4 != '') { $pdf_url4 = $ykd->PdfGen4($Id, '0', '4'); $pdf_url_sql .= ", pdf_url4='$pdf_url4'"; }
$urun_pdf_url5 = $db->VeriCek($urun_id, 'urunler', 'pdf_url5');
if ($urun_pdf_url5 != '') { $pdf_url5 = $ykd->PdfGen5($Id, '0', '5'); $pdf_url_sql .= ", pdf_url5='$pdf_url5'"; }
..
..
..
This is the sample of the code that causes delays. For the offline purchases if I click "approve" from the admin panel, it directly sends the first pdf the the PdfGen function (which is posting customer details to wordpress plugin, and receives the stamped pdf's url back)
The code controls in the "if statements" whether there is more than one pdf or not. If there's, it sends it to a different function PdfGen2 (that posts the info to a second plugin installed in another directory)
The problem is stamping in the plugin takes 3-4 second and each if statement waits that time to start controlling whether there is another pdf and if yes posting it to the plugin..
Can multithreading be used to send all the pdf's to the post functions at the same time? Without waiting each other to end? If yes, how?
from pthreads.
Each function appears to depend on the last function having run.
from pthreads.
It might be possible depending on the internals
from my understanding this part of the code:
$urun_pdf_url2 = $db->VeriCek($urun_id, 'urunler', 'pdf_url2');
if ($urun_pdf_url2 != '') { $pdf_url2 = $ykd->PdfGen2($Id, '0', '2'); $pdf_url_sql .= ", pdf_url2='$pdf_url2'";
is not dependent on the runs of the others, so it could run in a thread. But in the end it depends on what $ykd is and how it works internally.
The simple rule to follow there is: you should not attemp to share a database connection or any other kind of resource. And since simple DB checks are usualy fast, you can just do all that checks before you spawn the threads.
from pthreads.
Related Issues (20)
- Volatile isn't thread safe HOT 7
- Halting development of pthreads for 7.4 HOT 1
- Lost resource.
- Pool Completed Threaded Tasks Count Progress.
- Can not enable extension pthreads on PHP 7.2.15 Windows 10 Enterprise (x64) HOT 3
- sudo pecl install pthreads /usr/local/bin/pecl: 28: exec: /usr/local/bin/php: not found
- PHPIZE? HOT 1
- How to get unique php-extension instance for each php thread? HOT 6
- PHP 7.1.23 compile failed HOT 3
- Migrating to Pararell and Differences between these two extensions. HOT 1
- zend_mm_heap corrupted without sockets
- php-zts with pthreads not allocating tasks to free workers HOT 3
- Serialization of 'Closure' is not allowed in Worker HOT 5
- PHP7.4 HOT 2
- [BUG] PHP7.2 broken after this commit HOT 6
- Cannot install via pecl HOT 2
- Memory "leak" when passing large payload tasks to pool HOT 2
- windos load pthread.dll failed HOT 1
- Make not working HOT 1
- memory leak when pthreads in pthreads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pthreads.