MESSAGE
DATE | 2016-12-17 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] PNG threaded program
|
From learn-bounces-at-nylxs.com Sat Dec 17 19:01:40 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 396DB161312; Sat, 17 Dec 2016 19:01:40 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id 7EC85160E77; Sat, 17 Dec 2016 17:48:05 -0500 (EST) To: Samir Iabbassen From: Ruben Safir Message-ID: <4c6866e3-62e6-8cfc-e705-c597a05e76e5-at-mrbrklyn.com> Date: Sat, 17 Dec 2016 17:48:05 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5ED6952C672208D13FE39C20" X-Mailman-Approved-At: Sat, 17 Dec 2016 19:01:37 -0500 Subject: [Learn] PNG threaded program X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
This is a multi-part message in MIME format. --------------5ED6952C672208D13FE39C20 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit
I'm gotten quite a bit done with this, but I'm confused about some aspect of this code, which I've attached.
Essentially, I'm creating chunks through an object CHUNKY. I tried to make local copies of whatever I needed so that I can use them within threads. I put mutex in order to exclusively copy indexes of the output, and to copy sequential data from the file to the chunks, in order to allow for the chunks to run in threads as independent objects.
I then create the thread with the CHUNKY object which calls another thread which has CHUNKY objects. The idea was to detach the threads, and let them copy their payloads to the "canvas" which is the combined output, which they should be able to do independently from each other or the calling object.
When I use it with thread.join() it works fine, but I don't think this is optimal. When I use thread.detach(), which was my intent, it only runs a single call, or it segfaults. I think this is because the calling function ends maybe, before the threads can cascade? I'm not sure. I could use more experienced feedback.
-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
--------------5ED6952C672208D13FE39C20 Content-Type: text/x-c++src; name="main_png.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="main_png.cpp"
/* * ===================================================================================== * * Filename: main_png.cpp * * Description: PNG Project - main * * Version: 1.0 * Created: 11/30/2016 02:57:46 PM * Revision: 1.0 * Compiler: gcc * * Author: Ruben Safir (mn), ruben-at-mrbrklyn.com * Company: NYLXS Inc * * ===================================================================================== */ #include #include "png_proj.h"
int main(int argc, char **argv) { // const char * image_file_path = nullptr; const char * image_file_path = "/home/ruben/images/tzfat/tzfat_dawn_blended_fused.png"; //const char * image_file_path = "/home/ruben/photo_album/images/135-red_sea_1.png"; png_proj::Image pngtestfile{image_file_path}; // pngtestfile.read_png(); std::cout << "MAIN: line:" << __LINE__ << " char * image size==>" << sizeof(image_file_path) << std::endl; pngtestfile.read_signature(); pngtestfile.read_chunk(); // while(pngtestfile.getNext() < pngtestfile.get_end() ){ // std::cout << "Hey I am not Kosher Bird, yoy can't eat me!!" << std::endl; // }
return EXIT_SUCCESS; }
--------------5ED6952C672208D13FE39C20 Content-Type: text/plain; charset=UTF-8; name="makefile" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="makefile"
Q1hYOj1nKysgCkNYWEZMQUdTOj0tV2FsbCAtZ2dkYiAgLXBnIC1wdGhyZWFkCgpMREZMQUdT Oj0tTC91c3IvbG9jYWwvbGliL215c3FsIC1sbXlzcWxwcCAtbG15c3FsY2xpZW50IC1segoK Cm15cG5nIDoJcG5nX3Byb2oubyBtYWluLm8KCSR7Q1hYfSAgJHtDWFhGTEFHU30gLW8gbXlw bmcgIHBuZ19wcm9qLm8gbWFpbi5vCgptYWluLm8gOgltYWluX3BuZy5jcHAKCSR7Q1hYfSAk e0NYWEZMQUdTfSAgLW8gbWFpbi5vIC1jIG1haW5fcG5nLmNwcAoKcG5nX3Byb2oubyA6CXBu Z19wcm9qLmNwcAoJJHtDWFh9ICAke0NYWEZMQUdTfSAtbyBwbmdfcHJvai5vIC1jIHBuZ19w cm9qLmNwcAoKY2xlYW4JOiAKCXJtIHBuZ19wcm9qICoubyBtYWtlLmRlcHMKCXRvdWNoICou Y3BwICouaAoKaW5jbHVkZSBtYWtlLmRlcHMKbWFrZS5kZXBzOiAqLmNwcCA7IGdjYyAtTSAq LmNwcCA+JEAK --------------5ED6952C672208D13FE39C20 Content-Type: text/x-c++src; name="png_proj.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="png_proj.cpp"
/* * ===================================================================================== * * Filename: png_proj.cpp * * Description: PNG Project * * Version: 1.0 * Created: 11/15/2016 12:08:44 PM * Revision: none * Compiler: gcc * * Author: Ruben Safir (mn), ruben-at-mrbrklyn.com * Company: NYLXS Inc * * ===================================================================================== */ #include #include #include #include #include |
|