Thu Apr 18 17:24:06 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2016-12-01

LEARN

2024-04-18 | 2024-03-18 | 2024-02-18 | 2024-01-18 | 2023-12-18 | 2023-11-18 | 2023-10-18 | 2023-09-18 | 2023-08-18 | 2023-07-18 | 2023-06-18 | 2023-05-18 | 2023-04-18 | 2023-03-18 | 2023-02-18 | 2023-01-18 | 2022-12-18 | 2022-11-18 | 2022-10-18 | 2022-09-18 | 2022-08-18 | 2022-07-18 | 2022-06-18 | 2022-05-18 | 2022-04-18 | 2022-03-18 | 2022-02-18 | 2022-01-18 | 2021-12-18 | 2021-11-18 | 2021-10-18 | 2021-09-18 | 2021-08-18 | 2021-07-18 | 2021-06-18 | 2021-05-18 | 2021-04-18 | 2021-03-18 | 2021-02-18 | 2021-01-18 | 2020-12-18 | 2020-11-18 | 2020-10-18 | 2020-09-18 | 2020-08-18 | 2020-07-18 | 2020-06-18 | 2020-05-18 | 2020-04-18 | 2020-03-18 | 2020-02-18 | 2020-01-18 | 2019-12-18 | 2019-11-18 | 2019-10-18 | 2019-09-18 | 2019-08-18 | 2019-07-18 | 2019-06-18 | 2019-05-18 | 2019-04-18 | 2019-03-18 | 2019-02-18 | 2019-01-18 | 2018-12-18 | 2018-11-18 | 2018-10-18 | 2018-09-18 | 2018-08-18 | 2018-07-18 | 2018-06-18 | 2018-05-18 | 2018-04-18 | 2018-03-18 | 2018-02-18 | 2018-01-18 | 2017-12-18 | 2017-11-18 | 2017-10-18 | 2017-09-18 | 2017-08-18 | 2017-07-18 | 2017-06-18 | 2017-05-18 | 2017-04-18 | 2017-03-18 | 2017-02-18 | 2017-01-18 | 2016-12-18 | 2016-11-18 | 2016-10-18 | 2016-09-18 | 2016-08-18 | 2016-07-18 | 2016-06-18 | 2016-05-18 | 2016-04-18 | 2016-03-18 | 2016-02-18 | 2016-01-18 | 2015-12-18 | 2015-11-18 | 2015-10-18 | 2015-09-18 | 2015-08-18 | 2015-07-18 | 2015-06-18 | 2015-05-18 | 2015-04-18 | 2015-03-18 | 2015-02-18 | 2015-01-18 | 2014-12-18 | 2014-11-18 | 2014-10-18

Key: Value:

Key: Value:

MESSAGE
DATE 2016-12-18
FROM ruben safir
SUBJECT Re: [Learn] Threads and Object Methods
From learn-bounces-at-nylxs.com Sun Dec 18 21:24:31 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 3B935161312;
Sun, 18 Dec 2016 21:24:31 -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 4A91E160E77
for ; Sun, 18 Dec 2016 21:23:31 -0500 (EST)
Newsgroups: comp.lang.c++
References:
<6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com>

<7pSdnevF5InTn8rFnZ2dnUU78W3NnZ2d-at-brightview.co.uk>

To: learn-at-nylxs.com
From: ruben safir
Message-ID:
Date: Sun, 18 Dec 2016 21:23:30 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.5.1
MIME-Version: 1.0
In-Reply-To:
Subject: Re: [Learn] Threads and Object Methods
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: ,

Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: learn-bounces-at-nylxs.com
Sender: "Learn"

On 12/18/2016 09:15 PM, ruben safir wrote:
> On 12/18/2016 04:40 PM, Vir Campestris wrote:
>> You're missing the second parameter to the function. Perhaps if he'd
>> written
>>
>> Reader foo;
>> std::thread paint(&reader::read_chunk, &foo);
>>
>> it would have made more sense to you. You can pass args to the function,
>> which may include a pointer to an object of the type. I prefer to pass a
>> pointer to a static member function for the first parameter which takes
>> a pointer to an object of the class and invokes a corresponding
>> non-static member.
>>
>> Andy
>
>
> Not really. There are data members of the object that are dynamically altered
> and stored in the private encapsulation of the object which a a method handles
> inside the thread. read_chunk is a member of the Image class and it is
> assigned indexes within a block of memory, and a chunk of raw data. It
> interprets the block of memory and writes to the block of memory which is
> private to an instance of Image. The idea was to create a number of threads
> that write to the block, each in its assigned area, simultaneously in parallel.
>
> read_chunk looks like this
>
> void Image::read_chunk ( )
> {
> CHUNKY * new_chunk = set_chunk();//the chunk construction call is within
> std::cout << "Type " << new_chunk->type() << std::endl;
> std::cout << "Length " << new_chunk->length() << std::endl;
> std::cout << "CRC " << new_chunk->cr() << std::endl;
>
> if(new_chunk->type() == "IHDR")
> {
> std::cout << "we have a header chunk " << std::endl;
> IHDR * head = new IHDR;
> unsigned char * cur = new_chunk->data(); //NOTE:: cur is now point at the new heap for in CHNUNK and not the index for the file
> head->width = ntohl( *(reinterpret_cast(cur ) ) );
> cur += 4;
> head->height = ntohl( *(reinterpret_cast( cur ) ) );
> cur += 4;
> head->depth = *( reinterpret_cast( cur ) );
> cur++;
> head->color_type = *( reinterpret_cast( cur ) );
> cur++;
> head->compress = *( reinterpret_cast( cur ) );
> cur++;
> head->filter = *( reinterpret_cast( cur ) );
> cur++;
> head->interlace = *( reinterpret_cast( cur ) );
> cur++;
>
> canvas_size = static_cast(head->height) * static_cast(head->width) * blank_canvas_psize(*head);
> canvas = new unsigned char[ canvas_size ];
> std::cout << "Canvas made: " << static_cast(head->height) * static_cast(head->width) * blank_canvas_psize(*head) << " bytes" << std::endl;
> //char tmp;
> //std::cin >> tmp;
> }
>
> if(new_chunk->type() == "IDAT")
> {
> //confusion here. Do we want to create a new data array on the heap to pass through to the images for placement on canvas?
> //No. Not needed. Use the CHUNKY object instead. It already has the data array. Have the chunky obj schedule itself for
> //copy to the canvas
> set_canvas(*new_chunk); //SET MUTEX LOCK and assign canvas index to a CHUNKY object
> }
>
> if(new_chunk->type() == "IEND")
> {
> std::cout << "we have a IEND chunk " << std::endl;
> //set_index(get_index() + 12 + new_chunk->length() ) ;
> return;
> }
> std::thread ctch = getNext(); //calls this method in recursion
> ctch.join(); //I want this to be detached
> //read_chunk();
> return ;
> } /* ----- end of method Image::read_chunk ----- */
>
>


and I had to use a lamda for the thread

std::thread Image::getNext ()
{
std::cout << std::endl << "getNext" << std::endl;
// next_index();
std::thread paint( [this]{ read_chunk(); } );
std::cout << std::endl << "**created thread**" << paint.get_id() << std::endl;
return paint;
} /* ----- end of method Image::getNext ----- */


_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn

  1. 2016-12-01 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] Fwd: Patrolling the Dark Net,
  2. 2016-12-02 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Tutorial on threaded binary tree part 1: simple
  3. 2016-12-03 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Witner Labs
  4. 2016-12-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Nice lecture on Quantum Mechanics
  5. 2016-12-05 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] information access, copyright wars and DRM
  6. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  7. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  8. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  9. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] png data format
  10. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  11. 2016-12-06 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [Learn] png data format
  12. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] png data format
  13. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  14. 2016-12-06 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] png data format
  15. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  16. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [Hangout-NYLXS] png data format
  17. 2016-12-06 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  18. 2016-12-06 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  19. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  20. 2016-12-06 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Ocaml
  21. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [luny-talk] Humble Bundle O'Reilly UNIX books
  22. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] JT's words
  23. 2016-12-06 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] png data format
  24. 2016-12-07 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  25. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: png data format
  26. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  27. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  28. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] references to pointers
  29. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ returning lvalue references and pointers and refs
  30. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] const puzzle and literal type arguments
  31. 2016-12-11 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  32. 2016-12-12 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Fwd: Re: png data format
  33. 2016-12-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] gene phylogienics of homonids
  34. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Bit Depth
  35. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ Threads Workshop
  36. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Summer Jobs
  37. 2016-12-14 From: "Mancini, Sabin (DFS)" <Sabin.Mancini-at-dfs.ny.gov> Subject: [Learn] For Ruben ( + those in NYC Metro ) : Holiday Social Event
  38. 2016-12-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [dinosaur] Ceratopsid (Centrosaurinae:
  39. 2016-12-15 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [Learn] Happy Holidays
  40. 2016-12-15 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] zlib demo with vector::resize
  41. 2016-12-15 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  42. 2016-12-15 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: [dinosaur] Elephant bird nuclear genome fragments
  43. 2016-12-15 Christopher League <league-at-contrapunctus.net> Subject: [Learn] zlib demo with vector::resize
  44. 2016-12-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] zlib demo with vector::resize
  45. 2016-12-16 Christopher League <league-at-contrapunctus.net> Re: [Learn] zlib demo with vector::resize
  46. 2016-12-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] PNG Parallel Programming problem
  47. 2016-12-17 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [Hangout-NYLXS] I'm sure it's a coincidence, part n+1
  48. 2016-12-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] irc thread on the use of object methods in threads
  49. 2016-12-17 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] PNG threaded program
  50. 2016-12-18 ruben safir <ruben-at-mrbrklyn.com> Re: [Learn] Threads and Object Methods
  51. 2016-12-18 ruben safir <ruben-at-mrbrklyn.com> Re: [Learn] Threads and Object Methods
  52. 2016-12-18 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Look C++ is a functional programming language
  53. 2016-12-19 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] C++ Threading
  54. 2016-12-19 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ Threading
  55. 2016-12-19 ISOC-NY announcements <announce-at-lists.isoc-ny.org> Subject: [Learn] [isoc-ny] JOB: Telecommunications Policy Specialist -at- NTIA
  56. 2016-12-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] F'ing Mouse Pad
  57. 2016-12-20 mrbrklyn <mrbrklyn-at-panix.com> Subject: [Learn] Phylogenetic study worth noting
  58. 2016-12-21 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] Noobdy is home
  59. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] Noobdy is home
  60. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Noobdy is home
  61. 2016-12-21 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] thread concurancy
  62. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] thread concurancy
  63. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: lamda's in classes
  64. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: lamda's in classes
  65. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: thread concurancy
  66. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  67. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  68. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  69. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  70. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  71. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  72. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  73. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  74. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  75. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) thread concurancy
  76. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Threads and Object Methods
  77. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] I need help
  78. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Noobdy is home
  79. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] thread concurancy
  80. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] [Hangout-NYLXS] Marnchester by the Sea
  81. 2016-12-22 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] [Hangout-NYLXS] And be aware you were an unexcused
  82. 2016-12-22 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: thread concurancy
  83. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] HOPL (History of Programming Languages)
  84. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Noobdy is home
  85. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Tiny Compiler in many languages at Rosettacode.org
  86. 2016-12-25 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Google and C++
  87. 2016-12-25 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] phylogentics
  88. 2016-12-27 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] thread concurancy

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!