本文整理汇总了C++中Watcher类的典型用法代码示例。如果您正苦于以下问题:C++ Watcher类的具体用法?C++ Watcher怎么用?C++ Watcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Watcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: kevent
// Demultiplexing the I/O events
// Must be called in the loop thread.
int KqueueSelect::select(int timeout, WatcherList *activeList) {
int ret = -1;
ret = kevent(_kqueuefd, NULL, 0, _events, _evSize, NULL);
if (ret == -1)
{
// EINTR indicates epoll_wait was interrupted by a signal handler before
// any of the requested events occurred or the timeout expired.
if (errno != EINTR)
{
return -1;
}
return 0;
}
// Check what of the reqeusted events occurred on the file descriptors.
for (int i = 0; i < ret; ++i)
{
Watcher *w = (Watcher *)_events[i].udata;
int events = 0;
int filter = _events[i].filter;
if (filter == EVFILT_READ)
{
events |= kReadEvent;
}
if (filter == EVFILT_WRITE)
{
events |= kWriteEvent;
}
w->setActiveEvents(events);
activeList->push_back(w);
}
return 0;
}
开发者ID:betallcoffee,项目名称:ET,代码行数:37,代码来源:KqueueSelect.cpp
示例2: ABC_BridgeWatcherConnect
tABC_CC ABC_BridgeWatcherConnect(Wallet &self, tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
tABC_GeneralInfo *ppInfo = NULL;
const char *szServer = FALLBACK_OBELISK;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
// Pick a server:
if (isTestnet())
{
szServer = TESTNET_OBELISK;
}
else if (ABC_CC_Ok == ABC_GeneralGetInfo(&ppInfo, pError) &&
0 < ppInfo->countObeliskServers)
{
++gLastObelisk;
if (ppInfo->countObeliskServers <= gLastObelisk)
gLastObelisk = 0;
szServer = ppInfo->aszObeliskServers[gLastObelisk];
}
// Connect:
ABC_DebugLog("Wallet %s connecting to %s", self.id().c_str(), szServer);
watcher->connect(szServer);
exit:
ABC_GeneralFreeInfo(ppInfo);
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:31,代码来源:WatcherBridge.cpp
示例3: notify
void Watcher::notify(std::string name, std::string event) {
Watchers& w = gWatchers[name];
for (Watchers::iterator it=w.begin(); it!=w.end(); it++) {
Watcher * rw = *it;
rw->onEvent(name, event);
}
}
开发者ID:Devil-hmr,项目名称:AlloSystem,代码行数:7,代码来源:al_Watcher.cpp
示例4: ABC_BridgePrioritizeAddress
tABC_CC ABC_BridgePrioritizeAddress(Wallet &self,
const char *szAddress,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
bc::payment_address addr;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
if (szAddress)
{
if (!addr.set_encoded(szAddress))
{
cc = ABC_CC_Error;
ABC_DebugLog("Invalid szAddress %s\n", szAddress);
goto exit;
}
}
watcher->prioritize_address(addr);
exit:
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:25,代码来源:WatcherBridge.cpp
示例5: main
int main(int argc, char *argv[])
{
Watcher w;
cout<<w.init((char *)"../../shared/", NULL)<<endl;
w.watch();
return 0;
}
开发者ID:venkadaramanujam,项目名称:LSCNS,代码行数:7,代码来源:main.cpp
示例6: ABC_BridgeFilterTransactions
/**
* Filters a transaction list, removing any that aren't found in the
* watcher database.
* @param aTransactions The array to filter. This will be modified in-place.
* @param pCount The array length. This will be updated upon return.
*/
tABC_CC ABC_BridgeFilterTransactions(Wallet &self,
tABC_TxInfo **aTransactions,
unsigned int *pCount,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
tABC_TxInfo *const *end = aTransactions + *pCount;
tABC_TxInfo *const *si = aTransactions;
tABC_TxInfo **di = aTransactions;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
while (si < end)
{
tABC_TxInfo *pTx = *si++;
int height;
bc::hash_digest txid;
if (!bc::decode_hash(txid, pTx->szMalleableTxId))
ABC_RET_ERROR(ABC_CC_ParseError, "Bad txid");
if (watcher->get_tx_height(txid, height))
{
*di++ = pTx;
}
else
{
ABC_TxFreeTransaction(pTx);
}
}
*pCount = di - aTransactions;
exit:
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:41,代码来源:WatcherBridge.cpp
示例7: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Watcher w;
w.show();
return a.exec();
}
开发者ID:EleVenPerfect,项目名称:OTHERS,代码行数:8,代码来源:main.cpp
示例8: onStatusChange
/**
* Callback method that is called when child process changes status
* @param loop The loop in which the event was triggered
* @param watcher Internal watcher object
* @param revents Events triggered
*/
static void onStatusChange(struct ev_loop *loop, ev_child *watcher, int revents)
{
// retrieve the reader
Watcher *object = (Watcher *)watcher->data;
// call it
object->invoke();
}
开发者ID:CopernicaMarketingSoftware,项目名称:REACT-CPP,代码行数:14,代码来源:status.cpp
示例9: bridgeWatcherStop
Status
bridgeWatcherStop(Wallet &self)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
watcher->stop();
return Status();
}
开发者ID:codeaudit,项目名称:airbitz-core,代码行数:10,代码来源:WatcherBridge.cpp
示例10: bridgeWatcherDisconnect
Status
bridgeWatcherDisconnect(Wallet &self)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
watcher->disconnect();
return Status();
}
开发者ID:codeaudit,项目名称:airbitz-core,代码行数:10,代码来源:WatcherBridge.cpp
示例11: watcherSend
Status
watcherSend(Wallet &self, StatusCallback status, DataSlice tx)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
watcher->sendTx(status, tx);
return Status();
}
开发者ID:codeaudit,项目名称:airbitz-core,代码行数:10,代码来源:WatcherBridge.cpp
示例12: watcherSave
Status
watcherSave(Wallet &self)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
auto data = watcher->serialize();;
ABC_CHECK(fileSave(data, watcherPath(self)));
return Status();
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:11,代码来源:WatcherBridge.cpp
示例13: ABC_BridgeWatcherDisconnect
tABC_CC ABC_BridgeWatcherDisconnect(Wallet &self, tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
watcher->disconnect();
exit:
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:12,代码来源:WatcherBridge.cpp
示例14: watcherLoad
static Status
watcherLoad(Wallet &self)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
DataChunk data;
ABC_CHECK(fileLoad(data, watcherPath(self)));
if (!watcher->load(data))
return ABC_ERROR(ABC_CC_Error, "Unable to load serialized watcher");
return Status();
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:13,代码来源:WatcherBridge.cpp
示例15: Reactor_loop
void Reactor_loop(Reactor self, int32_t to) {
fd_t kqfd = self->poll.fileno;
struct kevent events[MAXEVENT];
void* fds[MAXEVENT];
uint8_t wr_end, rd_begin;
struct kevent* ev_end;
Watcher wt;
uint32_t* sig = &self->signal;
struct timespec ts;
struct timespec* timeout = NULL;
if(to != -1) {
time_t sec = to / 1000;
long nsec = (to - sec * 1000) * 1000000000;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
timeout = &ts;
}
int32_t count;
while(*sig == 0) {
wr_end = 0;
rd_begin = MAXEVENT;
count = kevent(kqfd, NULL, 0, events, MAXEVENT, timeout);
if(count == -1) {
if(errno == EINTR) {
return;
}
perror("Reactor_loop");
exit(-1);
}
ev_end = events + count;
for(struct kevent* p = events; p < ev_end; ++p) {
if(p->filter & EVFILT_WRITE) {
fds[wr_end++] = p->udata;
} else if(p->filter & EVFILT_READ) {
fds[--rd_begin] = p->udata;
}
}
for(uint8_t i = 0; i < wr_end; ++i) {
wt = (Watcher)fds[i];
wt->onCall(wt);
}
for(uint8_t i = rd_begin; i < MAXEVENT; ++i) {
wt = (Watcher)fds[i];
wt->onCall(wt);
}
}
}
开发者ID:codesun,项目名称:xetn,代码行数:49,代码来源:reactor_kqueue.c
示例16: gather_challenges
bool gather_challenges(unsigned_transaction& utx, Watcher& watcher)
{
utx.challenges.resize(utx.tx.inputs.size());
for (size_t i = 0; i < utx.tx.inputs.size(); ++i)
{
bc::input_point& point = utx.tx.inputs[i].previous_output;
if (!watcher.db().has_tx(point.hash))
return false;
bc::transaction_type tx = watcher.find_tx(point.hash);
utx.challenges[i] = tx.outputs[point.index].script;
}
return true;
}
开发者ID:snash779,项目名称:airbitz-core,代码行数:15,代码来源:Inputs.cpp
示例17: watcherBridgeRawTx
Status
watcherBridgeRawTx(Wallet &self, const char *szTxID,
DataChunk &result)
{
Watcher *watcher = nullptr;
ABC_CHECK(watcherFind(watcher, self));
bc::hash_digest txid;
if (!bc::decode_hash(txid, szTxID))
return ABC_ERROR(ABC_CC_ParseError, "Bad txid");
auto tx = watcher->find_tx(txid);
result.resize(satoshi_raw_size(tx));
bc::satoshi_save(tx, result.begin());
return Status();
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:16,代码来源:WatcherBridge.cpp
示例18: ABC_BridgeTxBlockHeight
tABC_CC
ABC_BridgeTxBlockHeight(Wallet &self, unsigned int *height, tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
*height = watcher->get_last_block_height();
if (*height == 0)
{
cc = ABC_CC_Synchronizing;
}
exit:
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:16,代码来源:WatcherBridge.cpp
示例19: ABC_BridgeTxHeight
tABC_CC
ABC_BridgeTxHeight(Wallet &self, const char *szTxId, unsigned int *height, tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
int height_;
bc::hash_digest txid;
Watcher *watcher = nullptr;
ABC_CHECK_NEW(watcherFind(watcher, self));
if (!bc::decode_hash(txid, szTxId))
ABC_RET_ERROR(ABC_CC_ParseError, "Bad txid");
if (!watcher->get_tx_height(txid, height_))
{
cc = ABC_CC_Synchronizing;
}
*height = height_;
exit:
return cc;
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:20,代码来源:WatcherBridge.cpp
示例20: main
int main()
{
cout << "launcher starting...\n";
if (daemon(1, 0) == -1)
{
perror("daemon");
return EXIT_FAILURE;
}
_LOG("launcher starting...");
Watcher w;
w.Add("flecs.trigger.agent", "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64; cd /dev/shm/work/flecs-rpc/.build/agent; ./flecs-agent-server;");
w.Add("flecs.trigger.master", "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64; cd /dev/shm/work/flecs-rpc/.build/master; ./flecs-master;");
w.Add("flecs.trigger.server", "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64; cd /dev/shm/work/flecs-rpc/.build/server; ./flecs-server;");
w.Add("flecs.trigger.client", "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64; cd /dev/shm/work/flecs-rpc/.build/client; ./flecs-client;");
w.Add("flecs.trigger.regen-fileset", "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64; rm -rf /usr/local/flecs/*; cd /dev/shm/work/flecs-rpc/.build/data/gen-fileset; ./gen-fileset;");
w.Watch();
_LOG("launcher ended.");
return 0;
}
开发者ID:pradeepjawahar,项目名称:flecs-rpc-archive,代码行数:25,代码来源:launcher.cpp
注:本文中的Watcher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论