🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #309613

Re: Szukam przykładu thread_pool

#309613
From: Borneq
Date: Sat, 13 Jan 2018 19:33
25 lines
1723 bytes
Albo :
#include "ctpl_stl.h"
#include <iostream>
#include <string>

void first(int id) { std::cout << "first hello from " << id << '\n'; }

struct Second { void operator()(int id) const { std::cout << "second 
hello from " << id << '\n'; } } second;

void third(int id, const std::string & additional_param) {}

int main() {
	ctpl::thread_pool p(2 /* two threads in the pool */);
	p.push(first); // function
	p.push(third, "additional_param");
	p.push([](int id) { std::cout << "hello from " << id << '\n'; }); // lambda
	p.push(std::ref(second)); // functor, reference
	p.push(const_cast<const Second &>(second)); // functor, copy ctor
	p.push(std::move(second)); // functor, move ctor
	printf("koniec\n");
	while(true);
}

są dwa wątki w p, ale jest aż 6 razy push, co robi push?
Technical Details
Message-ID: <p3dmu7$85n$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <p3d0dt$k1h$1@node2.news.atman.pl> <p3dmeq$8pr$1@node2.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Borneq <borneq@antyspam.hidden.pl>
Newsgroups: pl.comp.lang.c
Subject: Re: Szukam przykładu thread_pool
Date: Sat, 13 Jan 2018 20:33:28 +0100
Organization: ATMAN - ATM S.A.
Lines: 25
Message-ID: <p3dmu7$85n$1@node1.news.atman.pl>
References: <p3d0dt$k1h$1@node2.news.atman.pl> <p3dmeq$8pr$1@node2.news.atman.pl>
NNTP-Posting-Host: public-gprs352921.centertel.pl
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1515872007 8375 37.47.9.218 (13 Jan 2018 19:33:27 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Sat, 13 Jan 2018 19:33:27 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
In-Reply-To: <p3dmeq$8pr$1@node2.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit