/* Description: Creates a timerHeap, starts dispatching then creates * 100 timers which destroys themselves by callback. Heap is * then destroyed. * * Expected Result: Functions return zero */ TEST_F (CommonTimerTestC, createDestroyManyTimers) { struct timeval timeout; timerElement timer[100] = {NULL}; timerHeap heap = NULL; timeout.tv_sec = 0; timeout.tv_usec = 500; ASSERT_EQ (0, createTimerHeap(&heap)); ASSERT_EQ (0, startDispatchTimerHeap(heap)); for(int i=0; i<100 ;i++) { ASSERT_EQ (0, createTimer(&timer[i], heap, onTimerFire, &timeout, heap)); } sleep(2); ASSERT_EQ (0, destroyHeap(heap)); }
tdb_t TDBcreate(int id, file_t file, channel_t channel) { tdb_t tdb = (tdb_t) calloc(1, sizeof(tdb_r)); if (tdb==NULL) { mkerror(ERR_NULL,"failed calloc(size = %d)",sizeof(tdb_r)); return NULL; } timer = createTimer(); // printmsg("TDBcreate: %d %lx %s", id, file, dir); tdb->type = TDB; tdb->role = SERVER; tdb->db = ATindexedSetCreate(tdb_size, 75); if (tdb->db==NULL) { mkerror(ERR_NULL, "failed indexedSetCreate(size = %d)", tdb_size); return NULL; } tdb->file = file; tdb->count = tdb->last = 0; tdb->minMsgTime = 1000.0; tdb->id = id; #ifdef LINUX if (channel) { if (!tdb->file) tdb->role = CLIENT; tdb->channel.r = channel->r; tdb->channel.w = channel->w; } #endif if (tdb->file) TDBread(tdb); return tdb; }
void set_reduce_strong(lts_t lts){ int iter, set, *newmap, setcount, count, *tmp, *map; uint32_t i; mytimer_t timer; cell_t j; timer=createTimer(); startTimer(timer); lts_uniq(lts); lts_sort(lts); lts_set_type(lts,LTS_BLOCK); map=(int*)malloc(sizeof(int)*lts->states); newmap=(int*)malloc(sizeof(int)*lts->states); if (!map || !newmap ) Fatal(1,1,"out of memory"); for(i=0;i<lts->states;i++){ map[i]=0; } count=1; iter=0; for(;;){ MEMSTAT_CHECK; SetClear(-1); iter++; setcount=0; for(i=0;i<lts->states;i++){ set=EMPTY_SET; for(j=lts->begin[i];j<lts->begin[i+1];j++){ set=SetInsert(set,lts->label[j],map[lts->dest[j]]); } newmap[i]=SetGetTag(set); if (newmap[i]<0) { SetSetTag(set,setcount); newmap[i]=setcount; setcount++; } } Warning(2,"count is %d",setcount); if(count==setcount) break; count=setcount; tmp=map; map=newmap; newmap=tmp; } SetFree(); free(newmap); stopTimer(timer); /* reportTimer(timer,"computation of partition took"); */ lts_set_type(lts,LTS_LIST); lts->root=map[lts->root]; lts->root2=map[lts->root2]; for(j=0;j<lts->transitions;j++){ lts->src[j]=map[lts->src[j]]; lts->dest[j]=map[lts->dest[j]]; } lts->states=count; free(map); lts_uniq(lts); Warning(1,"reduction took %d iterations",iter); }
unsigned long OzMilliAlarm(unsigned long msec) { if (currentTask->timer) { destroyTimer(currentTask->timer); } currentTask->timer = createTimer(msec, alarmCallback, currentTask); startTimer(currentTask->timer); return 0; }
Timer::Timer(double val, double interval, TimerCallback cb) :_timerfd(createTimer()), _val(val), _interval(interval), _callback(std::move(cb)), _isStart(false) { }
TimerWindow::TimerWindow(QWidget *parent) : QWidget(parent) { #ifndef USE_DB_HELPER manager = new QNetworkAccessManager(this); #endif initLayout(); createTimer(); createConnect(); getWeekData(); }
MainWindow::MainWindow() { metaView = NULL; createTimer(); createActions(); createToolBar(); createErrorTabs(); createStatusBar(); scaleFactor = 1.0; setWindowFlags(Qt::WindowStaysOnTopHint); loadSettings(); }
void ICACHE_FLASH_ATTR wifi_softap(void){ if(read_user_config(&user_config)){ printf("user config restored\n"); createTimer(user_config.ssid,user_config.pwd); } else{ printf("wifi new\n"); config_wifi_new(); // createTimerWifi(); } }
unsigned long OzMilliSleep(unsigned long msec) { struct WaitQueue *wq; if (currentTask->timer) { destroyTimer(currentTask->timer); } wq = wqCreate(); currentTask->timer = createTimer(msec, &sleepCallback, wq); startTimer(currentTask->timer); sleepOn(wq); return 0; }
Configure::Configure(QWidget *parent, OBS *obs) : QDialog(parent), ui(new Ui::Configure), mOBS(obs) { ui->setupUi(this); createTimer(); connect(timer, SIGNAL(timeout()), parent, SLOT(refreshView())); proxySettingsSetup(); connect(ui->listWidget, SIGNAL(currentRowChanged(int)), ui->stackedWidget, SLOT(setCurrentIndex(int))); ui->listWidget->setCurrentRow(0); }
std::shared_ptr<consensus::yac::Yac> YacInit::createYac(std::string network_address, std::shared_ptr< uvw::Loop> loop, ClusterOrdering initial_order) { uint64_t delay_seconds = 5; return Yac::create(YacVoteStorage(), createNetwork(std::move(network_address), initial_order.getPeers()), createCryptoProvider(), createTimer(std::move(loop)), initial_order, delay_seconds * 1000); }
void GLWindow::init() { setAttribute(Qt::WA_DeleteOnClose); createSlider(); createButton(); createTimer(); setupLayout(); setupConnections(); timerStart(); }
unsigned long TimerMgr::createTimerCommon(int n, Timer **timer, unsigned long addr, unsigned short count) { while( n-- ) { if( *timer == NULL ) { TimerResource *tr; tr = timerResourceMgr.allocTimerResource(); *timer = createTimer(addr, count, tr); return tr->getTimerAddress(); } timer++; } return 0; }
/* Description: Creates a timerHeap, starts dispatching then creates a * timer which destroys itself in it's callback. Heap is * then destroyed. * * Expected Result: Functions return zero */ TEST_F (CommonTimerTestC, createDestroyTimer) { struct timeval timeout; timerElement timer = NULL; timerHeap heap = NULL; timeout.tv_sec = 0; timeout.tv_usec = 500; ASSERT_EQ (0, createTimerHeap(&heap)); ASSERT_EQ (0, startDispatchTimerHeap(heap)); ASSERT_EQ (0, createTimer(&timer, heap, onTimerFire, &timeout, heap)); sleep(2); ASSERT_EQ (0, destroyHeap(heap)); }
void FindTscTicksPerSecond(uint32_t numSamples) { TscTestData tscTestData = {0}; rtems_id timerID; /* begin... */ syslog(LOG_INFO, "Determining TSC ticks per second...\n"); rtems_task_ident(RTEMS_SELF, RTEMS_LOCAL, &tscTestData.taskID); timerID = createTimer(); tscTestData.buf = (uint32_t *)malloc(numSamples*sizeof(uint32_t)); if(tscTestData.buf == NULL) { syslog(LOG_INFO, "Can't allocate bmData.buf !!"); return; } tscTestData.bufsize = numSamples; startTimer(timerID, 1/* ticks*/, timerService, (void *)&tscTestData); rtems_event_set eventSet = 0; rtems_event_receive(RTEMS_EVENT_13, RTEMS_WAIT|RTEMS_EVENT_ANY, 0, &eventSet); //dump timing info to syslog... getTimingInfo(&tscTestData); free(tscTestData.buf); }
void CdrCamera::startAWMD() { if(!mAwmdTimerID) { if(mAwmdTimerCallback == NULL) { db_error("%s %d, awmd timer call back not set\n", __FUNCTION__, __LINE__); return; } if(createTimer(mCaller, &mAwmdTimerID, mAwmdTimerCallback) < 0) { db_error("%s %d, create timer failed\n", __FUNCTION__, __LINE__); return; } } db_msg("%s %d\n", __FUNCTION__, __LINE__); if (mHC && (mAWMDing == false)) { db_msg("%s %d\n", __FUNCTION__, __LINE__); mHC->setAWMoveDetectionListener(this); mHC->startAWMoveDetection(); mHC->setAWMDSensitivityLevel(1); mAWMDing = true; } }
///////////////////////////////////////////////////////////////////////////// // init ///////////////////////////////////////////////////////////////////////////// bool Vigasoco::init(std::string name) { // calls template method to perform platform specific initialization if (!platformSpecificInit()){ _errorMsg = "platformSpecificInit() failed"; return false; } // creates the game driver _driver = createGameDriver(name); if (!_driver){ _errorMsg = "unknown game " + name; return false; } // calls template method to create the palette createPalette(); if (!_palette){ _errorMsg = "createPalette() failed"; return false; } // inits the palette (the last 2 colors are used by the core to display information) int numColors = _driver->getVideoInfo()->colors; // TODO: VGA // Cambiar para no poner 256 a fuego _palette->init(256); // pruebas VGA // init the colors used by the core to display information /* _palette->setColor(numColors + 0, 0x00, 0x00, 0x00); _palette->setColor(numColors + 1, 0xff, 0xff, 0xff); */ // TODO: VGA6, mientras probamos con VGA, metemos esto a fuego en el color 253 y 254 _palette->setColor(253, 0x00, 0x00, 0x00); _palette->setColor(254, 0xff, 0xff, 0xff); // inits the fonts used by the core _fontManager = new FontManager(_palette, numColors/2); _fontManager->init(); // creates the FileLoader FileLoader *fl = new FileLoader(); // calls template method to add custom loaders addCustomLoaders(fl); // inits the game driver (load files, decode gfx, preprocessing, etc) if (!_driver->init(_palette)){ // calls template method to remove custom loaders removeCustomLoaders(fl); delete fl; _errorMsg = "driver->init() failed\n" + _driver->getError(); return false; } // calls template method to remove custom loaders removeCustomLoaders(fl); // deletes the FileLoader delete fl; // calls template method to get a DrawPlugin createDrawPlugin(); if (!_drawPlugin){ _errorMsg = "createDrawPlugin() failed"; return false; } // inits the DrawPlugin with the selected GameDriver if (!_drawPlugin->init(_driver->getVideoInfo(), _palette)){ _errorMsg = "drawPlugin->init() failed"; return false; } // notify the driver that the drawPlugin has been initialized _driver->videoInitialized(_drawPlugin); // creates the input handler _inputHandler = new InputHandler(); // calls template method to add input plugins addCustomInputPlugins(); // inits the input handler if (!_inputHandler->init(_driver)){ _errorMsg = "inputHandler->init() failed"; return false; } // calls template method to get a high resolution timer createTimer(); // creates the timing handler _timingHandler = new TimingHandler(); // inits the timing handler if (!_timingHandler->init(_timer, _driver->getNumInterruptsPerSecond(), _driver->getNumInterruptsPerVideoUpdate(), _driver->getnumInterruptsPerLogicUpdate())){ _errorMsg = "timerHandler->init() failed"; return false; } // calls template method to get a AudioPlugin createAudioPlugin(); if (!_audioPlugin){ _errorMsg = "createAudioPlugin() failed"; return false; } // inits the AudioPlugin with the selected GameDriver if (!_audioPlugin->init(/* TODO: _driver->getAudioInfo() */)){ _errorMsg = "audioPlugin->init() failed"; return false; } // notify the driver that the drawPlugin has been initialized _driver->audioInitialized(_audioPlugin); // creates the async thread createAsyncThread(); if (!_asyncThread){ _errorMsg = "createAsyncThread() failed"; return false; } // calls template method to perform specific actions after initialization has been completed initCompleted(); return true; }
int main(int argc, char *argv[]){ cl_uint numPlatforms; cl_platform_id* clSelectedPlatformID = NULL; int err; // error code returned from api calls int data[DATA_SIZE]; // original data set given to device int results[DATA_SIZE]; // results returned from device unsigned int correct; // number of correct results returned size_t global; // global domain size for our calculation size_t local; // local domain size for our calculation cl_device_id device_id; cl_context context; cl_command_queue commands; cl_program program; cl_kernel kernel; cl_mem input; // device memory used for the input array cl_mem output; // device memory used for the output array if(parseArgs(argc, argv)){ return 0; } // Fill our data set with random int values unsigned int count = DATA_SIZE; //////////////////////////////////////////////////////////////////////////////// // Simple compute kernel which computes the collatz of an input array // const char *KernelSource = fileToString("gpuFunctions.c"); //get Platform clGetPlatformIDs(0, NULL, &numPlatforms); clSelectedPlatformID = (cl_platform_id*)malloc(sizeof(cl_platform_id)*numPlatforms); err = clGetPlatformIDs(numPlatforms, clSelectedPlatformID, NULL); //get Device err = clGetDeviceIDs(clSelectedPlatformID[0], CL_DEVICE_TYPE_GPU, 1, &device_id, NULL); if (err != CL_SUCCESS) { printf("Error: Failed to create a device group!\n"); return EXIT_FAILURE; } //create context context = clCreateContext(0, 1, &device_id, NULL, NULL, &err); if (!context) { printf("Error: Failed to create a compute context!\n"); return EXIT_FAILURE; } // Create a command commands // commands = clCreateCommandQueue(context, device_id, 0, &err); if (!commands) { printf("Error: Failed to create a command commands!\n"); return EXIT_FAILURE; } // Create the compute program from the source buffer // program = clCreateProgramWithSource(context, 1, (const char **) & KernelSource, NULL, &err); if (!program) { printf("Error: Failed to create compute program!\n"); return EXIT_FAILURE; } // Build the program executable // err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); if (err != CL_SUCCESS) { size_t len; char buffer[2048]; printf("Error: Failed to build program executable!\n"); clGetProgramBuildInfo(program, device_id, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &len); printf("%s\n", buffer); exit(1); } // Create the compute kernel in the program we wish to run // kernel = clCreateKernel(program, "allToOne", &err); if (!kernel || err != CL_SUCCESS) { printf("Error: Failed to create compute kernel!\n"); exit(1); } // Create the input and output arrays in device memory for our calculation // input = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * count, NULL, NULL); output = clCreateBuffer(context, CL_MEM_WRITE_ONLY, sizeof(float) * count, NULL, NULL); if (!input || !output) { printf("Error: Failed to allocate device memory!\n"); exit(1); } timer t = createTimer(); for(int i =0;i<rep;i++){ initData(data); // Write our data set into the input array in device memory // err = clEnqueueWriteBuffer(commands, input, CL_TRUE, 0, sizeof(float) * count, data, 0, NULL, NULL); if (err != CL_SUCCESS) { printf("Error: Failed to write to source array!\n"); exit(1); } // Set the arguments to our compute kernel // err = 0; err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &input); err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &output); err |= clSetKernelArg(kernel, 2, sizeof(unsigned int), &count); if (err != CL_SUCCESS) { printf("Error: Failed to set kernel arguments! %d\n", err); exit(1); } // Get the maximum work group size for executing the kernel on the device // err = clGetKernelWorkGroupInfo(kernel, device_id, CL_KERNEL_WORK_GROUP_SIZE, sizeof(local), &local, NULL); if (err != CL_SUCCESS) { printf("Error: Failed to retrieve kernel work group info! %d\n", err); exit(1); } // Execute the kernel over the entire range of our 1d input data set // using the maximum number of work group items for this device // global = count; err = clEnqueueNDRangeKernel(commands, kernel, 1, NULL, &global, &local, 0, NULL, NULL); if (err) { printf("Error: Failed to execute kernel!\n"); return EXIT_FAILURE; } // Wait for the command commands to get serviced before reading back results // clFinish(commands); // Read back the results from the device to verify the output // err = clEnqueueReadBuffer( commands, output, CL_TRUE, 0, sizeof(float) * count, results, 0, NULL, NULL ); if (err != CL_SUCCESS) { printf("Error: Failed to read output array! %d\n", err); exit(1); } } double timeEnd = getTime(t); // Validate our results // correct = 0; for(int i = 0; i < arraySize; i++) { if(results[i] >= 0){ correct++; if(i==0){ printf("%d",results[i]); }else{ printf(",%d",results[i]); } } } printf("\n"); // Print a brief summary detailing the results printf("Computed '%d/%d' values to 1!\n", correct, arraySize); printf("TIME- %f\n",timeEnd); // Shutdown and cleanup clReleaseMemObject(input); clReleaseMemObject(output); clReleaseProgram(program); clReleaseKernel(kernel); clReleaseCommandQueue(commands); clReleaseContext(context); return 0; }
void VoreenApplication::initialize() { if (initialized_) { if (tgt::LogManager::isInited()) LWARNING("init() Application already initialized. Skip."); return; } // // Command line parser // prepareCommandParser(); cmdParser_.execute(); // // tgt initialization // tgt::InitFeature::Features featureset; if (appFeatures_ & APP_CONSOLE_LOGGING) featureset = tgt::InitFeature::ALL; else featureset = tgt::InitFeature::Features(tgt::InitFeature::ALL &~ tgt::InitFeature::LOG_TO_CONSOLE); tgt::init(featureset, logLevel_); // detect documents path first, needed for log file #ifdef WIN32 TCHAR szPath[MAX_PATH]; // get "my documents" directory if (SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, szPath) == S_OK) documentsPath_ = szPath; #else if (getenv("HOME") != 0) documentsPath_ = getenv("HOME"); #endif // HTML logging if (appFeatures_ & APP_HTML_LOGGING) { #ifdef VRN_DEPLOYMENT LogMgr.reinit(documentsPath_); #endif if (logFile_.empty()) logFile_ = name_ + "-log.html"; // add a file logger tgt::Log* log = new tgt::HtmlLog(logFile_); log->addCat("", true, logLevel_); LogMgr.addLog(log); } // log version VoreenVersion::logAll("voreen.VoreenApplication"); #ifdef VRN_DEPLOYMENT LINFO("Deployment build."); #endif // // Path detection // // detect base path based on program location string prog = cmdParser_.getProgramPath(); basePath_ = "."; // cut path from program location string::size_type p = prog.find_last_of("/\\"); if (p != string::npos) { basePath_ = prog.substr(0, p); prog = prog.substr(p + 1); } // try to find base path starting at program path basePath_ = tgt::FileSystem::absolutePath(findBasePath(basePath_)); LINFO("Base path: " << basePath_); // mac app resources path #ifdef __APPLE__ appBundleResourcesPath_ = findAppBundleResourcesPath(); if (appBundleResourcesPath_.empty()) LERROR("Application bundle's resources path could not be detected!"); else LINFO("Application bundle's resources path: " << appBundleResourcesPath_); #endif // shader path if (appFeatures_ & APP_SHADER) { #if defined(__APPLE__) && defined(VRN_DEPLOYMENT) shaderPath_ = appBundleResourcesPath_ + "/glsl"; #else shaderPath_ = findShaderPath(basePath_); #endif } // data path if (appFeatures_ & APP_DATA) { dataPath_ = findDataPath(basePath_); cachePath_ = dataPath_ + "/cache"; temporaryPath_ = dataPath_ + "/tmp"; volumePath_ = findVolumePath(basePath_); #if defined(__APPLE__) && defined(VRN_DEPLOYMENT) fontPath_ = appBundleResourcesPath_ + "/fonts"; texturePath_ = appBundleResourcesPath_ + "/textures"; documentationPath_ = appBundleResourcesPath_ + "/doc"; #else fontPath_ = dataPath_ + "/fonts"; texturePath_ = dataPath_ + "/textures"; documentationPath_ = findDocumentationPath(basePath_); #endif } // log location of HTML log to console if ((appFeatures_ & APP_HTML_LOGGING) && !logFile_.empty()) { std::string logPath = tgt::FileSystem::absolutePath(logFile_); LINFO("HTML log file: " << logPath); } // core pseudo module is always included addModule(new CoreModule()); // // Modules // if (appFeatures_ & APP_AUTOLOAD_MODULES) { LDEBUG("Loading modules from module registration header"); addAllModules(this); if (modules_.empty()) { LWARNING("No modules loaded"); } else { std::vector<std::string> moduleNames; for (size_t i=0; i<modules_.size(); i++) moduleNames.push_back(modules_[i]->getName()); LINFO("Modules: " << strJoin(moduleNames, ", ")); } } else { LDEBUG("Module auto loading disabled"); } // init timer schedulingTimer_ = createTimer(&eventHandler_); eventHandler_.addListenerToFront(this); initialized_ = true; }
TutorialStateContext::TutorialStateContext (TutorialDlg &tutorialDlg) : m_tutorialDlg (tutorialDlg) { createStates (); createTimer (); }
void SpyFrame::initSecond() { createTimer(std::tr1::bind(&SpyFrame::eachSecond, this), 1000); }