🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Borneq Wed, 30 Aug 2017 13:16
Sprytne wskaźniki a dll czy shared object
#309416
Author: Borneq
Date: Wed, 30 Aug 2017 13:16
21 lines
1766 bytes
Mam coś takiego :
std::shared_ptr<Configuration> conf = nullptr;
conf = std::make_shared<Configuration>();
conf->Set("hbase.zookeeper.quorum", FLAGS_zookeeper);
conf->SetInt("hbase.client.cpu.thread.pool.size", FLAGS_threads);

conf jest użyte do clienta:
auto tn = std::make_shared<TableName>(folly::to<TableName>(FLAGS_table));
auto client = std::make_unique<Client>(*conf);

potem auto table = client->Table(*tn);

teraz chcę w funkcji eksportowanej zrobić:
table->Put(*MakePutColumn(family, qualifier, value));

Myślałem by table było wskaźnikiem, polem struktury Envir, wskaźnik na 
tę strukturę byłby podawany do wszystkich funkcji eksportowanych. Byłby 
na początku przydzielany a na końcu zwalniany.
Teraz sprytne wskaźniki komplikują sprawę, bo najlepiej aby na zewnątrz 
metoda ta była widziana jako czyste C. A może nie ? wtedy można by 
korzystać ze stringów na przykład.
Re: Sprytne wskaźniki a dll czy shared object
#309417
Author: Borneq
Date: Wed, 30 Aug 2017 13:44
17 lines
1433 bytes
W dniu 30.08.2017 o 15:16, Borneq pisze:
> potem auto table = client->Table(*tn);

Konkretnie :
   auto client = std::make_unique<Client>(*conf);
   auto table = client->Table(*tn);

table jest sprytnym wskaźnikiem
jeśli będę miał funkcję eksportowaną:

Table *soGetTable(Cleitn *client, char *name)
{
//...tn na podstawie nazwy,
     return client->Table(*tn).get();  //<====== get()!
}
to mi zwolni wskaźnik, ponieważ chyba jest unique_ptr<Client>
i tu mam kłopot
Re: Sprytne wskaźniki a dll czy shared object
#309418
Author: Borneq
Date: Wed, 30 Aug 2017 13:47
7 lines
1251 bytes
W dniu 30.08.2017 o 15:44, Borneq pisze:
> to mi zwolni wskaźnik, ponieważ chyba jest unique_ptr<Client>
> i tu mam kłopot

std::unique_ptr<Table> Client::Table(const TableName &table_name) {
   return std::make_unique<hbase::Table>(table_name, async_connection_);
}
Re: Sprytne wskaźniki a dll czy shared object
#309419
Author: Borneq
Date: Wed, 30 Aug 2017 16:17
11 lines
1404 bytes
W dniu 30.08.2017 o 15:47, Borneq pisze:
> W dniu 30.08.2017 o 15:44, Borneq pisze:
>> to mi zwolni wskaźnik, ponieważ chyba jest unique_ptr<Client>
>> i tu mam kłopot
> 
> std::unique_ptr<Table> Client::Table(const TableName &table_name) {
>    return std::make_unique<hbase::Table>(table_name, async_connection_);
> }

Robię kontenery: mam struktury które przydzielam i normalnie zwalniam a 
ich pola to sprytne wskaźniki.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads