Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1011725 // websMadeByProgram_parallel_buggy - await() problem

JavaX fragment (include)

static L<Web> websMadeByProgram_parallel_buggy(S progID) ctex {
  // TODO: clean up file handle in case of error
  IterableIterator<S> l = scanLog_iterator(progID, "webs-made.txt");
  fS src = progID;
  final new L<Pair<Web, Int>> webs;
  
  int poolSize = numberOfCores(), queueSize = 20;
  NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS);
  
  try {
    int i = 0;
    for (fS s : l) {
      ++i;
      final int _i = i;
      e.execute(r { pcall {
        SoftwareMadeWeb o = cast unstructure(s);
        Web web = o.web;
        if (web == null)
          web = (Web) unstructure(o.structure);
        if (web != null) synchronized(webs) {
          webs.add(pair(web_intern(web_setSourceIfEmpty(web, src)), _i));
        }
      }});
    }
    e.await(); // ConcurrentModificationException sometimes??
    //e.shutdown();
    //e.awaitTermination(1, TimeUnit.DAYS);
  } finally {
    e.shutdown();
  }
  
  time "Sort" {
    sortBySecondOfPairs_inPlace(webs);
  }
  ret firstOfPairs(webs);
}

Author comment

Began life as a copy of #1011722

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011725
Snippet name: websMadeByProgram_parallel_buggy - await() problem
Eternal ID of this version: #1011725/1
Text MD5: 521ddcc70b4cdca1ab0e817e01817b1c
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-03 16:38:01
Source code size: 1070 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 416 / 453
Referenced in: [show references]